In graph theory, the Stoer–Wagner algorithm is a recursive algorithm to solve the minimum cut problem in undirected weighted graphs with non-negative weights. It was proposed by Mechthild Stoer and Frank Wagner in 1995. The essential idea of this algorithm is to shrink the graph by merging the most intensive vertices, until the graph only contains two combined vertex sets. At each phase, the algorithm finds the minimum s {\displaystyle s} - t {\displaystyle t} cut for two vertices s {\displaystyle s} and t {\displaystyle t} chosen at its will. Then the algorithm shrinks the edge between s {\displaystyle s} and t {\displaystyle t} to search for non s {\displaystyle s} - t {\displaystyle t} cuts. The minimum cut found in all phases will be the minimum weighted cut of the graph. A cut is a partition of the vertices of a graph into two non-empty, disjoint subsets. A minimum cut is a cut for which the size or weight of the cut is not larger than the size of any other cut. For an unweighted graph, the minimum cut would simply be the cut with the least edges. For a weighted graph, the sum of all edges' weight on the cut determines whether it is a minimum cut. In practice, the minimum cut problem is always discussed with the maximum flow problem, to explore the maximum capacity of a network, since the minimum cut is a bottleneck in a graph or network.
Stoer–Wagner minimum cut algorithm Let G = ( V , E , w ) {\displaystyle G=(V,E,w)} be a weighted undirected graph. Suppose that s , t ∈ V {\displaystyle s,t\in V} . The cut is called an s {\displaystyle s} - t {\displaystyle t} cut if exactly one of s {\displaystyle s} or t {\displaystyle t} is in S {\displaystyle S} . The minimal cut of G {\displaystyle G} that is also an s {\displaystyle s} - t {\displaystyle t} cut is called the s {\displaystyle s} - t {\displaystyle t} min-cut of G {\displaystyle G} . This algorithm starts by finding an s {\displaystyle s} and a t {\displaystyle t} in V {\displaystyle V} , and an s-t min-cut ( S , T ) {\displaystyle (S,T)} of G {\displaystyle G} . For any pair { s , t } {\displaystyle \left\{s,t\right\}} , there are two possible situations: either ( S , T ) {\displaystyle (S,T)} is a global min-cut of G {\displaystyle G} , or s {\displaystyle s} and t {\displaystyle t} belong to the same side of the global min-cut of G {\displaystyle G} . Therefore, the global min-cut can be found by checking the graph G ∪ { s t } / { s , t } {\displaystyle G\cup \{st\}/\left\{s,t\right\}} , which is the graph after merging vertices s {\displaystyle s} and t {\displaystyle t} into a new vertex s t {\displaystyle st} . During the merging, if s {\displaystyle s} and t {\displaystyle t} are connected by an edge then this edge disappears. If s {\displaystyle s} and t {\displaystyle t} both have edges to some vertex v {\displaystyle v} , then the weight of the edge from the new vertex s t {\displaystyle st} to v {\displaystyle v} is w ( s , v ) + w ( t , v ) {\displaystyle w(s,v)+w(t,v)} . The algorithm is described as:
MinimumCutPhase ( G , w , a ) {\displaystyle (G,w,a)}
A ← { a } {\displaystyle A\gets \left\{a\right\}}
while A ≠ V {\displaystyle \ A\neq V}
add to A {\displaystyle A} the most tightly connected vertex end store the cut in which the last remaining vertex is by itself (the "cut-of-the-phase") shrink G {\displaystyle G} by merging the two vertices (s, t) added last (the value of "cut-of-the-phase" is the value of minimum s, t cut.)
MinimumCut ( G , w , a ) {\displaystyle (G,w,a)}
… excerpt ends here. Continue reading the full article.

![Stoer–Wagner algorithm: A min-cut of a weighted graph having min-cut weight 4[1]](https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Stoer_wagner-example-min-cut.gif/330px-Stoer_wagner-example-min-cut.gif?utm_source=en.wikipedia.org&utm_campaign=parser&utm_content=thumbnail)
