Stoer–Wagner algorithm
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 - t cut for two vertices s and t chosen at its will. Then the algorithm shrinks the edge between s and t to search for non s - 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... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.
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 - t cut for two vertices s and t chosen at its will. Then the algorithm shrinks the edge between s and t to search for non s - 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. Let G=(V,E,w) be a weighted undirected graph. Suppose that s,t\in V . The cut is called an s - t cut if exactly one of s or t is in S . The minimal cut of G that is also an s - t cut is called the s - t min-cut of G . This algorithm starts by finding an s and a t in V , and an s-t min-cut (S,T) of G . For any pair \left\{s,t\right\} , there are two possible situations: either (S,T) is a global min-cut of G , or s and t belong to the same side of the global min-cut of G . Therefore, the global min-cut can be found by checking the graph G\cup\{st\}/\left\{s,t\right\} , which is the graph after merging vertices s and t into a new vertex st . During the merging, if s and t are connected by an edge then this edge disappears. If s and t both have edges to some vertex v , then the weight of the edge from the new vertex st to v is w(s,v)+w(t,v) . The algorithm is described as: MinimumCutPhase (G,w,a) A\gets\left\{a\right\} while \ A\ne V add to 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 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) while |V|>1 MinimumCutPhase (G,w,a) if the cut-of-the-phase is lighter than the current minimum cut then store the cut-of-the-phase as the current minimum cut The algorithm works in phases. In the MinimumCutPhase, the subset A of the graphs vertices grows starting with an arbitrary single vertex until A is equal to V . In each step, the vertex which is outside of A , but most tightly connected with A is added to the set A . This procedure can be formally shown as: add vertex z\notin A such that w(A,z)=\max\{w(A,y) \mid y\notin A\} , where w(A,y) is the sum of the weights of all the edges between A and y . So, in a single phase, a pair of vertices s and t , and a min s\text{-}t cut C is determined. After one phase of the MinimumCutPhase, the two vertices are merged as a new vertex, and edges from the two vertices to a remaining vertex are replaced by an edge weighted by the sum of the weights of the previous two edges. Edges joining the merged nodes are removed. If there is a minimum cut of G separating s and t , the C is a minimum cut of G . If not, then the minimum cut of G must have s and t on a same side. Therefore, the algorithm would merge them as one node. In addition, the MinimumCut would record and update the global minimum cut after each MinimumCutPhase. After n-1 phases, the minimum cut can be determined. To prove the correctness of this algorithm, we need to prove that the cut given by MinimumCutPhase is in fact a minimum s\text{-}t cut of the graph, where s and t are the two vertices last added in the phase. Therefore, a lemma is shown below: Lemma 1: MinimumCutPhase returns a minimum s\text{-}t -cut of G . Let C=(X,\overline{X}) be an arbitrary s\text{-}t cut, and CP be the cut given by the phase. We must show that W(C)\ge W(CP) . Observe that a single run of MinimumCutPhase gives us an ordering of all the vertices in the graph (where a is the first and s and t are the two vertices added last in the phase). We say the vertex v is active if v and the vertex added just before v are in opposite sides of the cut. We prove the lemma by induction on the set of active vertices. We define A_v as the set of vertices added to A before v , and C_v to be the set of edges in C with both of their ends in A_v \cup \{v\} , i.e. C_v \subseteq C is the cut induced by A_v \cup \{v\} . We prove, for each active vertex v , w(A_v,v)\le w(C_v) Let v_0 be the first active vertex. By the definition of these two quantities, w(A_{v_0},v_0) and w(C_{v_0}) are equivalent. A_{v_0} is simply all vertices added to A before v_0 , and the edges between these vertices and v_0 are the edges that cross the cut C . Therefore, as shown above, for active vertices v and u , with v added to A before u : w(A_u,u)=w(A_v,u)+w(A_u-A_v,u) w(A_u,u)\le w(C_v)+w(A_u-A_v,u) by induction, w(A_v,u)\le w(A_v,v)\le w(C_v) w(A_{u},u)\le w(C_{u}) since w(A_u-A_v,u) contributes to w(C_{u}) but not to w(C_{v}) (and other edges are of non-negative weights) Thus, since t is always an active vertex since the last cut of the phase separates s from t by definition, for any active vertex t : w(A_t,t)\le w(C_t)=w(C) Therefore, the cut of the phase is at most as heavy as C . // Adjacency matrix implementation of Stoer–Wagner min cut algorithm. // // Running time: // O(|V|^3) include using namespace std; pair > globalMinCut(vector > mat) { pair > best = {INT_MAX, {}}; int n = mat.size(); vector > co(n); for (int i = 0; i w = mat[0]; size_t s = 0, t = 0; for (int it = 0; it O(E log V) with prio. queue w[t] = INT_MIN; s = t, t = max_element(w.begin(), w.end()) - w.begin(); for (int i = 0; i const int maxn = 550; const int inf = 1000000000; int n, r; int edge[maxn][maxn], dist[maxn]; bool vis[maxn], bin[maxn]; void init() { memset(edge, 0, sizeof(edge)); memset(bin, false, sizeof(bin)); } int contract( int &s, int &t ) // Find s,t { memset(dist, 0, sizeof(dist)); memset(vis, false, sizeof(vis)); int i, j, k, mincut, maxc; for (i = 1; i maxc) { k = j; maxc = dist[j]; } if (k == -1) return mincut; s = t; t = k; mincut = maxc; vis[k] = true; for (j = 1; j ans) mincut = ans; if (mincut == 0) return 0; for (j = 1; j ==External links== StoerWagnerMinCut.java - a Java library that implements the Stoer–Wagner algorithm
Cite this
"Stoer–Wagner algorithm". 1743797872. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1283990532 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy