Advertisement
Guest User

Untitled

a guest
Jan 1st, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. from igraph import *
  4. from random import randint
  5. import random
  6.  
  7. edges = [(0,1), (0,2), (0,3), (1,2), (1,3), (2,3), (3,8), (4,5), (4,6), (4,7), (4,8), (5,6), (5,7), (5,8), (6,7), (6,8), (7,8), (1,6)]
  8. g = Graph(edges)
  9.  
  10. mincut_value = sys.maxint
  11. mincut_edges = None
  12. for i in range(0, 100):
  13.     source = randint(0, 8)
  14.     target = randint(0, 8)
  15.     cut = g.mincut(source, target)
  16.     if mincut_value > cut.value:
  17.         mincut_value = cut.value
  18.         mincut_edges = cut.cut
  19.  
  20. print mincut_value
  21.  
  22. g.vs["label"] = range(0, 9)
  23. g.es[mincut_edges]["color"] = "red"
  24. plot(g)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement