NetworkX

Previous topic

networkx.MultiGraph.degree_iter

Next topic

networkx.MultiGraph.number_of_edges

networkx.MultiGraph.size

MultiGraph.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