How this calculation works
Compress every pairwise minimum-cut value of a small undirected capacitated graph into one weighted tree. The smallest tree-edge weight along the path between two vertices gives their minimum-cut value in the original graph. The output also includes a full pair-value matrix, making the compression directly inspectable.
λ_G(s,t)=min_{e∈path_T(s,t)} w_T(e); an appropriate lightest path-edge separation gives an original minimum cut.A worked example
Triangle capacities c12=3,c23=2,c13=1: pair cuts λ12=4, λ13=λ23=3. Tree 1–2 weight 4 and 2–3 weight 3 encodes these values.
Good to know
Simple undirected graph, n=2–25, integer capacities 0–1,000,000. Exact integer residual flows; disconnected graphs and zero capacities allowed. Tree not necessarily unique; displayed diagonal zero is a convention. No directed cut tree.
Reference: Method reference (opens in a new tab) ↗
What the tree encodes
A minimum cut between s and t is a vertex separation with s on one side and t on the other, minimizing the sum of original capacities crossing that separation. A Gomory–Hu tree represents these values for every pair at once.
The tree is not generally a subgraph of the input. Its edges summarize cut relationships and carry cut values, so interpreting a tree edge as a physical link or its weight as the original link capacity would be incorrect.
Compare this with the Minimum edge cut calculator with edge disjoint path witnesses. One terminal-pair cut does not expose a compressed all-pairs cut structure.
Reading a pair from a tree path
Find the unique path between the chosen vertices in the returned tree. Its smallest edge weight equals their minimum-cut capacity in the original graph; adding the path weights answers a different question and gives the wrong cut value.
Deleting an appropriate minimum-weight edge on that path partitions the tree vertices into a minimum-cut separation. The separation concerns the same labels in the original graph, where its crossing capacities can be summed to check the witness.
Constructing the cut tree
The construction uses repeated exact source-to-target flow computations and maintains a parent tree. Each cut reorganizes the vertices on its source side and updates the corresponding tree-edge capacity, rather than independently computing every possible pair.
For n vertices, n minus one flow computations suffice for the construction. The independent reference checks every pair with direct minimum cuts, ensuring that a plausible-looking tree has not hidden an incorrect reparenting or capacity update.
Working through the triangle capacities
The default triangle has capacities three on 1–2, two on 2–3 and one on 1–3. Separating vertex one costs four, while separating vertex three costs three; these cuts help determine the pairwise values.
One valid tree has edge 1–2 of weight four and edge 2–3 of weight three. Its path minimum gives four for pair 1,2 and three for pairs 1,3 and 2,3, matching direct cut enumeration.
Understanding disconnected and zero cases
An absent edge supplies no capacity, and a zero-capacity edge contributes nothing to a cut. Vertices separated by a zero-capacity cut have pairwise minimum-cut value zero, even if an unweighted drawing shows a path between them.
Disconnected inputs are accepted and require zero-weight tree links between the separate regions. Such links complete the summary tree without asserting that the original graph contains a transport connection between those regions.
Entering an undirected capacity model
Use two through twenty-five vertices with nonnegative integer capacities through one million. Every unordered pair appears at most once. A missing row means no edge; a present row with zero capacity is allowed and remains structurally distinct in the input.
The undirected capacity model permits capacity in either travel direction without imposing a directed-network cut definition. Directed networks do not generally admit this same tree representation, so reversing or discarding directions silently would change the problem.
Interpreting the matrix and nonuniqueness
The matrix is symmetric, and its off-diagonal entries are exact cut capacities for the bounded integer input. The displayed diagonal zero is a formatting convention because a source-to-itself separation is not part of the minimum-cut query.
Different valid Gomory–Hu trees may encode the same matrix. Compare all-pairs path minima and cut witnesses rather than expecting one unique tree shape, and avoid interpreting the summary as a maximum-spanning or shortest-path optimization.
A few questions, answered
Do tree path weights add together?
No. The minimum edge weight along the path gives the pairwise cut value.
Must the tree use original graph edges?
No. It is a cut summary on the same vertex labels.
Can the input be disconnected?
Yes. Pairs in separate components have cut value zero and the summary uses zero-weight links.
Why is the matrix diagonal zero?
It is an explicit display convention; source-to-itself cuts are not queried.