Return iterator that return degree(n) or (n,degree(n)) for all n in nbunch. If nbunch is ommitted, then iterate over *all* nodes. nbunch: can be a singleton node, a string (which is treated as a singleton node), or any iterable container of of nodes. (It can be an iterable or an iterator, e.g. a list, set, graph, file, etc.) If None, all nodes in the graph will be used. If with_labels=True, iterator will return an (n,degree(n)) tuple of node and degree. Any nodes in nbunch but not in the graph will be (quietly) ignored. Reimplemented from networkx::base::Graph. Definition at line 1375 of file base.py. 01375 : """Return iterator that return degree(n) or (n,degree(n)) for all n in nbunch. If nbunch is ommitted, then iterate over *all* nodes. nbunch: can be a singleton node, a string (which is treated as a singleton node), or any iterable container of of nodes. (It can be an iterable or an iterator, e.g. a list, set, graph, file, etc.) If None, all nodes in the graph will be used. If with_labels=True, iterator will return an (n,degree(n)) tuple of node and degree. Any nodes in nbunch but not in the graph will be (quietly) ignored. """ # prepare nbunch if nbunch is None: # include all nodes via iterator bunch=self.nodes_iter() elif nbunch in self: # if nbunch is a single node bunch=[nbunch] else: # if nbunch is a sequence of nodes try: bunch=[n for n in nbunch if n in self] except TypeError: raise NetworkXError, "nbunch is not a node or a sequence of nodes." # nbunch ready if with_labels: # yield tuple (n,degree) for n in bunch: yield (n,len(self.succ[n])+len(self.pred[n])) else: for n in bunch: yield len(self.succ[n])+len(self.pred[n]) def in_degree_iter(self,nbunch=None,with_labels=False):
