Return the average shortest path length.
The average shortest path length is the sum of path lengths d(u,v) between all pairs of nodes (assuming the length is zero if v is not reachable from v) normalized by n*(n-1) where n is the number of nodes in G.
Parameters: | G : NetworkX graph weighted : bool, optional, default=False
|
---|
Notes
If weighted=True and the graph has no ‘weight’ edge attribute the value 1 will be used.
Examples
>>> G=nx.path_graph(5)
>>> print nx.average_shortest_path_length(G)
2.0