Hi,

> how is the average path length calculated for graphs that contain more than 
> one component? 
Depending on the value of the "unconn" parameter of the function, there are two 
possible behaviours:

- If "unconn" is False, igraph simply assumes for every disconnected vertex 
pair that their distance is N, where N is the number of vertices in the graph.

- If "unconn" is True, igraph calculates distances for the connected pairs only 
and then takes the average of these values. In your graph, it goes as follows:

path_lengths = [pl for pl in sum(g.shortest_paths(), []) if pl > 0 and pl != 
float('inf')]

Now, sum(path_lengths) is 68 and len(path_lengths) is 34, so you get a result 
of 2.0.

-- 
T.


_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to