NetworkX

Previous topic

networkx.Graph.size

Next topic

networkx.Graph.number_of_selfloops

Quick search

networkx.Graph.number_of_edges

Graph.number_of_edges(u=None, v=None)

Return the number of edges between two nodes.

Parameters:

u,v : nodes

If u and v are specified, return the number of edges between u and v. Otherwise return the total number of all edges.

Examples

>>> G=nx.path_graph(4)
>>> G.number_of_edges()
3
>>> G.number_of_edges(0,1) 
1
>>> e=(0,1)
>>> G.number_of_edges(*e)
1