NetworkX

Previous topic

networkx.DiGraph.out_degree_iter

Next topic

networkx.DiGraph.number_of_edges

networkx.DiGraph.size

DiGraph.size(weighted=False)

Return the number of edges.

Parameters:

weighted : boolean, optional (default=False)

If True return the sum of the edge weights.

Returns:

nedges : int

The number of edges in the graph.

See also

number_of_edges

Examples

>>> G = nx.Graph()   # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_path([0,1,2,3])
>>> G.size()
3
>>> G = nx.Graph()   # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_edge('a','b',weight=2)
>>> G.add_edge('b','c',weight=4)
>>> G.size()
2
>>> G.size(weighted=True)
6