All shortest paths for weighted graphs with networkx? -


i have graph composed 2 different sets of edges. first set made edges of weight 1 (list 1). second set made edges of weight 2 (list 2). first, create graph networkx , use add_edges_from add list 1 , list 2. compute shortest paths in weighted graph. i'm looking analogous of "all_shortest_paths" weights (looks "dijkstra" module not allow know possible routes between given source , given target). if try use "all_shortest_path" weighted links (3-tuples, 2 nodes , weight) error . can me? lot!

here simple example show how all_shortest_paths() works

import networkx nx import stringio edges = stringio.stringio(""" b 1 bb 1 b c 2 bb c 2 c d 1 d 10""") g = nx.read_weighted_edgelist(edges, nodetype=str) print list(nx.all_shortest_paths(g, 'a', 'd', weight='weight')) # [['a', 'b', 'c', 'd'], ['a', 'bb', 'c', 'd']] 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -