Graph Theory Review

Minimum Cut Algorithms

Given a graph G = (V, E), a cut of G is a partition of the vertices into two, non-empty sets X and \overline{X} = V - X. The weight of a cut is defined as the number of edges between sets X and \overline{X} if G is unweighted, or the sum of the weights of all edges between sets X and \overline{X} if G is weighted (each edge has an associated, non-negative weight).

When the weight of a cut C = \{X, \overline{X}\} is minimal for a graph G (that is, no other cut of G has a lesser weight), then the cut is known as a minimum cut or a min-cut. For example, given this weighted graph:

The cut {{0, 6}, {4, 1, 5, 2, 3, 7}} has weight 13:

And the min-cut is {{0, 4, 1, 5}, {2, 6, 3, 7}} (weight 4):

Unlike this example, a graph will sometimes have multiple min-cuts, all of equal weight. A minimum cut algorithm determines one of them as well as the min-cut weight.


Minimum Cut Algorithms

A min-cut of a weighted graph
having min-cut weight 4

stoer_wagner_mincut

template <class UndirectedGraph, class P, class Q, class R, class S, class T, class U>
weight_type
stoer_wagner_mincut(const UndirectedGraph& g,
    const bgl_named_params<P, Q, R, S, T, U>& params = all defaults);

The stoer_wagner_mincut function determines a min-cut and the min-cut weight of an undirected graph.

A cut of a graph G is a partition of the vertices into two, non-empty sets. The weight of such a partition is the number of edges between the two sets if G is unweighted, or the sum of the weights of all edges between the two sets if G is weighted. A min-cut is a cut having the least weight.

Sometimes a graph has multiple min-cuts, but all have the same weight. The stoer_wagner_mincut function determines exactly one of the min-cuts as well as its weight.

Where Defined

boost/graph/stoer_wagner_mincut.hpp

Parameters

IN: const UndirectedGraph& g

An undirected graph. The graph type must be a model of Vertex List Graph and Incidence Graph.

Named Parameters

IN: weight_map(WeightMap weights)

The weight or length of each edge in the graph. The WeightMap type must be a model of Readable Property Map and its value type must be Less Than Comparable and summable. The key type of this map needs to be the graph's edge descriptor type.
Default: boost::make_unit_weight_property_map(g)

OUT: parity_map(ParityMap parities)

The algorithm computes a min-cut, which divides the set of vertices into two, non-empty sets. The stoer_wagner_mincut function records which of the two sets that each vertex belongs to by setting the parity to true (representing one set) or false (for the other). ParityMap must be a model of a Writable Property Map and its value type should be an unspecified-bool-type. The key type must be the graph's vertex descriptor type.
Default: boost::null_property_map

IN: vertex_index_map(VertexIndexMap vertexIndices)

This maps each vertex to an integer in the range [0, num_vertices(g)). This is only necessary if the default is used for the assignment, index-in-heap, or wA maps. VertexIndexMap must be a model of Readable Property Map. The value type of the map must be an integer type. The key type must be the graph's vertex descriptor type.
Default: get(boost::vertex_index, g)

UTIL: assignment_map(AssignmentMap assignments)

AssignmentMap must be a model of Read/Write Property Map. The key and value types must be the graph's vertex descriptor type.
Default: A boost::iterator_property_map using a std::vector of num_vertices(g) vertex descriptors.

UTIL: index_in_heap_map(IndexInHeapMap indicesInHeap)

IndexInHeapMap must be a model of Read/Write Property Map. The key type must be the graph's vertex descriptor type. The value type must be a size type.
Default: A boost::iterator_property_map using a std::vector of num_vertices(g) size type objects.

UTIL: wA_map(WAMap wAs)

WAMap must be a model of Read/Write Property Map. The key type must be the graph's vertex descriptor type. The value type must be the weight type (typename boost::property_traits<WeightMap>::value_type).
Default: A boost::iterator_property_map using a std::vector of num_vertices(g) weight type objects.

Returns

The weight of the min-cut

Throws

std::invalid_argument

If num_vertices(g) is less than 2

Complexity

The time complexity is O(V·E + V2 log V).

Example

The file examples/stoer_wagner.cpp contains an example of calculating a min-cut of a weighted, undirected graph and its min-cut weight.

References