Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. from igraph import *
  2.  
  3. g = Graph(16, directed=True)
  4. g.add_edges([
  5. (0,1), (0,2), (0,3),
  6. (1,4),
  7. (2, 4), (2,5),
  8. (3,5), (3,6),
  9. (4,7), (4,8),
  10. (5,8), (5,9), (5,10),
  11. (6,10),
  12. (7,11),
  13. (8,11), (8,12), (8,13),
  14. (9,13),
  15. (10,13), (10,14),
  16. (11,15),
  17. (12,15),
  18. (13,15),
  19. (14,15)
  20. ])
  21.  
  22. ww=[
  23. 10, 12, 15,
  24. 5,
  25. 5, 15,
  26. 15, 10,
  27. 3, 10,
  28. 10, 5, 20,
  29. 20,
  30. 4,
  31. 4, 5, 20,
  32. 20,
  33. 20, 7,
  34. -550,
  35. -580,
  36. -590,
  37. -600
  38. ]
  39.  
  40. # print g.shortest_paths_dijkstra(source=0, target=15, weights=ww, mode=OUT)
  41. # print g.shortest_paths_bellman_ford(source=0, target=15, weights=ww, mode=OUT)
  42. print g.shortest_paths(source=0, target=11, weights=ww)
  43. print g.shortest_paths(source=0, target=12, weights=ww)
  44. print g.shortest_paths(source=0, target=13, weights=ww)
  45. print g.shortest_paths(source=0, target=14, weights=ww)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement