Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from igraph import *
- g = Graph(16, directed=True)
- g.add_edges([
- (0,1), (0,2), (0,3),
- (1,4),
- (2, 4), (2,5),
- (3,5), (3,6),
- (4,7), (4,8),
- (5,8), (5,9), (5,10),
- (6,10),
- (7,11),
- (8,11), (8,12), (8,13),
- (9,13),
- (10,13), (10,14),
- (11,15),
- (12,15),
- (13,15),
- (14,15)
- ])
- ww=[
- 10, 12, 15,
- 5,
- 5, 15,
- 15, 10,
- 3, 10,
- 10, 5, 20,
- 20,
- 4,
- 4, 5, 20,
- 20,
- 20, 7,
- -550,
- -580,
- -590,
- -600
- ]
- # print g.shortest_paths_dijkstra(source=0, target=15, weights=ww, mode=OUT)
- # print g.shortest_paths_bellman_ford(source=0, target=15, weights=ww, mode=OUT)
- print g.shortest_paths(source=0, target=11, weights=ww)
- print g.shortest_paths(source=0, target=12, weights=ww)
- print g.shortest_paths(source=0, target=13, weights=ww)
- print g.shortest_paths(source=0, target=14, weights=ww)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement