g=Graph()
g = Graph({1:{2:'2',4:'5'}, 2:{1:'2',3:'3',4:'1'},3:{2:'3',4:'1',5:'2'},4:{1:'5',2:'1',3:'1',5:'4'},5:{3:'2',4:'4'}}); 
g.plot(edge_labels=True) // plots the graph with edges with their weights

g.shortest_path(1,5)
[1, 4, 5] //output

g.shortest_path(3,1)
[3, 2, 1] //output

g.shortest_path(2,5)
[2,4,5] //output

Kreyszig-21.3-7-U (last edited 2010-12-18 10:19:16 by koumudi)