Reputation: 865
I want to get the sum of weights (total cost/distance encountered) of a given path in a networkx multigraph.
It's like the current shortest_path_length() function but I plan to use it on the paths returned by the all_simple_paths() function. Is there a way to do that?
I can't just iterate over all the nodes in the path because since it's a multigraph, I will need the key for that given path to be able to know which edge is used. Thank you.
Upvotes: 2
Views: 2995
Reputation: 865
I got it. I created a subgraph instead of every output path from all_simple_paths() and just obtained their sum over an attribute by using size() function.
Upvotes: 0