NetworkX

Previous topic

networkx.LabeledDiGraph.degree

Next topic

networkx.LabeledDiGraph.copy

Quick search

networkx.LabeledDiGraph.degree_iter

LabeledDiGraph.degree_iter(nbunch=None, weighted=False)

Return an iterator for (node, degree).

The node degree is the number of edges adjacent to that node.

Parameters:

nbunch : list, iterable

A container of nodes that will be iterated through once (thus it should be an iterator or be iterable). Each element of the container should be a valid node type: any hashable type except None. If nbunch is None, return all edges data in the graph. Nodes in nbunch that are not in the graph will be (quietly) ignored.

weighted : False|True

If the graph is weighted return the weighted degree (the sum of edge weights).

Examples

>>> G=nx.path_graph(4)
>>> list(G.degree_iter(0)) # node 0 with degree 1
[(0, 1)]
>>> list(G.degree_iter([0,1]))
[(0, 1), (1, 2)]