Find minimum s-t cut in a flow network
Submissions: 770   Accuracy:


  Difficulty: Medium   Marks: 4

Given an adjacency matrix and 2 integers S and T. The task is to find minimum capacity s-t cut of the given network. 
An s-t cut is a cut that requires the source ‘s’ and the sink ‘t’ to be in different subsets, and it consists of edges going from the source’s side to the sink’s side. The capacity of an s-t cut is defined by the sum of the capacity of each edge in the cut-set. 

The first line consists of T test cases. The first line of every test case consists of V number of vertices. The second line of every test case consists of V*V spaced integers consisting of the weight of edge from ith to jth index. The third line of every test case consists of S and T.

Single line output all the vertices which take the minimum cut from one vertex to other.If there is no mincut edge print -1.



0 16 13 0 0 0 0 0 10 12 0 0 0 4 0 0 14 0 0 0 9 0 0 20 0 0 0 7 0 4 0 0 0 0 0 0
0 5
1 3 4 3 4 5 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.