TypeError: 'generator' object is not subscriptable when indexing networkx.all_pairs_shortest_path_length result
Error: TypeError when subscripting the result of networkx.all_pairs_shortest_path_length In NetworkX 2.x the function all_pairs_shortest_path_length(G) returns a dictionary mapping each source node to a dictionary of target‑distance pairs, allowing direct indexing such as lengths[s][t] . Starting with version 3.0 the function was changed to return a lazy gen