wenont / GNN

0 stars 0 forks source link

Calculate average shortest path length: Graph is not strongly connected. #14

Open wenont opened 3 hours ago

wenont commented 3 hours ago

When calculating the average shortest path length, I used nx.average_shortest_path_length(G) in the framework networkx.

Then I got: networkx.exception.NetworkXError: Graph is not strongly connected. with the dataset AIDS.

According to NetworkX API,

Changed in version 3.0: An exception is raised for directed graphs that are not strongly connected.

Any solutions?

wenont commented 3 hours ago
>>>G = nx.Graph([(1, 2), (3, 4)])
>>>for C in (G.subgraph(c).copy() for c in nx.connected_components(G)):
    print(nx.average_shortest_path_length(C))
1.0
1.0