NetworkX

Previous topic

networkx.center

Next topic

networkx.shortest_path

networkx.average_shortest_path_length

average_shortest_path_length(G, weighted=False)

Return the average shortest path length.

Parameters:

G : NetworkX graph

weighted : bool, optional, default=False

If true use edge weights on path. If False, use 1 as the edge distance.

Examples

>>> G=nx.path_graph(4)
>>> print nx.average_shortest_path_length(G)
1.25