java - How to get the cut-set using the Edmonds–Karp algorithm? - Stack Overflow
I implemented the Edmonds–Karp algorithm using the Pseudocode that I found in the Edmonds–Karp algorithm wiki page: http://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm
It works great, yet the algorithm output is the max flow value(min cut value), I need to the list of edges that this cut contains
I tried to change the algorithm, with no success, can you guys help?
java algorithm pseudocode edmonds-karp share|improve this question edited Oct 26 '15 at 15:12
6871423
If you already have the flow, then compute the residual graph. Then do a depth first search from the source (or breadth first search, I don't think it matters), to compute the vertices in one half of the cut (S). The remaining vertices are in the other half of your cut, T.
This gives you your cut (S, T). If you specifically want the edges between S and T, you could iterate through all the edges, selecting the ones which connect S and T. (Though there may a be a more eleegant way to do this last part.)
share|improve this answer answered Mar 21 '11 at 17:04
can u explain the meanings of the numbers in the F nXn matrix?and how do I use them exactly?
@ciochPep: The matrix F gives the flow across each edge in the graph to achieve maximum flow -- essentially it's this that the Edmonds Karp algorithm is designed to compute. This also makes calculating the residual graph easy: it's simply the difference of the matrix C - the matrix F.
If you already know the maximal flow, then the minimal cut is (S, T), where S is the set of vertices reachable from the source in the residual network, T is the complementary set. Edges that connect a vertex from S and a vertex from T belong to the cut.
share|improve this answer answered Mar 21 '11 at 16:48
3,08911221
I only know the min-cut value...not the set
@ciochPep You said you implemented Edmonds-Karp? It finds the flow together with the value.
@ciochPep F[i,j] iss the flow along the edge from i to j. In a real algorithm it's probably represented as a list of edges, not a matrix
Here's some pointers to help clarify how to do this for anyone in the future.
To find the S vertices, do a BFS (or DFS) search from source vertex, only following edges in which some capacity for flow is remaining. (In other words, the non-saturated edges). These ones by definition cannot be in the mincut.
To find the T vertices perform a BFS (or DFS) search from the sink vertex, only connecting to vertices that were not already added to the S set. These can have residual flow, or could be fully saturated, it doesn't matter. Because you are performing BFS from the sink, you'll need to make sure you follow the opposite direction the edge is pointed if the graph is directed. NOTE: It's important to only include vertices that can be reached from the sink in your T set, otherwise you'll end up including edges in your min-cut that do not belong there. (This is what threw me for a long time.)
Once you have these two sets of vertices you can then iterate over all the edges of the graph. Anyone that has a source node in S and a target node in T is part of your min-cut. It's important to note, though, that this is just one of many possible min-cuts. It's much more time intensive to find all the possible S-T min-cuts in a graph.
Hope this helps any future internet people trying to figure this out! Good luck!
Not the answer you're looking for?	Browse other questions tagged java algorithm pseudocode edmonds-karp or ask your own question.	asked
Edmonds-Karp Algorithm for a graph which has nodes with flow capacities
Edmonds Karp algorithm and 0 1 capacities
How does Edmonds-karp algorithm actually computes the shortest path?
Cormen's “Introduction to algorithms” 3rd Edition - Edmonds-karps-Algorithm - Lemma 26.7
Why is Edmond Karps faster than Ford-Fulkerson?
java - How to get the cut-set using the Edmonds–Karp algorithm? - Stack Overflow
I implemented the Edmonds–Karp algorithm using the Pseudocode that I found in the Edmonds–Karp algorithm wiki page: http://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm
It works great, yet the algorithm output is the max flow value(min cut value), I need to the list of edges that this cut contains
I tried to change the algorithm, with no success, can you guys help?
java algorithm pseudocode edmonds-karp share|improve this question edited Oct 26 '15 at 15:12
6871423
If you already have the flow, then compute the residual graph. Then do a depth first search from the source (or breadth first search, I don't think it matters), to compute the vertices in one half of the cut (S). The remaining vertices are in the other half of your cut, T.
This gives you your cut (S, T). If you specifically want the edges between S and T, you could iterate through all the edges, selecting the ones which connect S and T. (Though there may a be a more eleegant way to do this last part.)
share|improve this answer answered Mar 21 '11 at 17:04
can u explain the meanings of the numbers in the F nXn matrix?and how do I use them exactly?
@ciochPep: The matrix F gives the flow across each edge in the graph to achieve maximum flow -- essentially it's this that the Edmonds Karp algorithm is designed to compute. This also makes calculating the residual graph easy: it's simply the difference of the matrix C - the matrix F.
If you already know the maximal flow, then the minimal cut is (S, T), where S is the set of vertices reachable from the source in the residual network, T is the complementary set. Edges that connect a vertex from S and a vertex from T belong to the cut.
share|improve this answer answered Mar 21 '11 at 16:48
3,08911221
I only know the min-cut value...not the set
@ciochPep You said you implemented Edmonds-Karp? It finds the flow tog
ether with the value.
@ciochPep F[i,j] iss the flow along the edge from i to j. In a real algorithm it's probably represented as a list of edges, not a matrix
Here's some pointers to help clarify how to do this for anyone in the future.
To find the S vertices, do a BFS (or DFS) search from source vertex, only following edges in which some capacity for flow is remaining. (In other words, the non-saturated edges). These ones by definition cannot be in the mincut.
To find the T vertices perform a BFS (or DFS) search from the sink vertex, only connecting to vertices that were not already added to the S set. These can have residual flow, or could be fully saturated, it doesn't matter. Because you are performing BFS from the sink, you'll need to make sure you follow the opposite direction the edge is pointed if the graph is directed. NOTE: It's important to only include vertices that can be reached from the sink in your T set, otherwise you'll end up including edges in your min-cut that do not belong there. (This is what threw me for a long time.)
Once you have these two sets of vertices you can then iterate over all the edges of the graph. Anyone that has a source node in S and a target node in T is part of your min-cut. It's important to note, though, that this is just one of many possible min-cuts. It's much more time intensive to find all the possible S-T min-cuts in a graph.
Hope this helps any future internet people trying to figure this out! Good luck!
Not the answer you're looking for?	Browse other questions tagged java algorithm pseudocode edmonds-karp or ask your own question.	asked
Edmonds-Karp Algorithm for a graph which has nodes with flow capacities
Edmonds Karp algorithm and 0 1 capacities
How does Edmonds-karp algorithm actually computes the shortest path?
Cormen's “Introduction to algorithms” 3rd Edition - Edmonds-karps-Algorithm - Lemma 26.7
Why is Edmond Karps faster than Ford-Fulkerson?