graph - Can python-igraph be used for min s-t cut? -


can python-igraph used min s-t cut?

i want minimum cost cut cuts designated source , sink nodes.

thanks!

yep.

from igraph import graph random import randint g = graph.grg(100, 0.2)        # generate geometric random graph g.es["capacity"] = [randint(0, 1000) in xrange(g.ecount())] cut = g.maxflow(0, 99, "capacity") 

cut.membership gives membership of each vertex (0-1 vector), cut[0] gives vertices on 1 side of cut, cut[1] gives other, cut.value gives value of cut.

[all credit goes @tamás]


Comments