Bipartite b-matching 2026-10-25
For a bipartite graph with bipartition and nonnegative integer bounds , a bipartite b-matching is an edge subset whose degree of a vertex is at most at each . Taking gives a matching in a graph. To maximize , build a flow network with arcs of flow network edge capacity for , arcs of flow network edge capacity one for , and arcs of flow network edge capacity for . The integral max-flow theorem gives an integral optimum. Select precisely the middle arcs with flow one. Flow conservation identifies their endpoint degrees with the outside arc flows, and the flow value is . Conversely, every such edge subset supplies a feasible flow of that value. This proves the reduction and its optimality.
Cut capacity Created 2026-10-07 Updated 2026-10-18
The cut capacity of , with the complement of a set, isOnly outward directed edges contribute; incoming and internal edges contribute nothing.[ref]
FordFulkerson.java. Algorithms, 4th edition by Robert Sedgewick and others; Sedgewick and Wayne, FordFulkerson.java, check method, lines 196–203: sum capacities only from the source side to its complement
Here is the accounting behind the bound, using nonnegative original edge amounts in a finite flow network. Sum the divergence of a flow over the vertices in :An edge with both endpoints in appears once with a plus sign at its tail and once with a minus sign at its head, so those contributions cancel. An outward edge appears only with a plus sign; an incoming edge appears only with a minus sign. Since , and every other vertex satisfies flow conservation, the left side is the flow value. ThusThe inequality uses two facts separately: each forward flow is at most its flow network edge capacity, and each backward flow is nonnegative. This is the weak duality bound underlying the max-flow min-cut theorem. It is an accounting proof, requiring no choice of augmenting paths.
For in the running example, explicitly add the two divergences of a flow:The internal edge cancels. The edge is a genuine original directed edge entering , so its flow is subtracted; this is different from a backward edge in a residual network. Its flow network edge capacity is neither added to nor subtracted from cut capacity, which remains .
Equality in the bound holds precisely when every outward edge is saturated and every incoming edge carries zero flow, becauseand every term is nonnegative. For the two outward edges are saturated and there are no incoming edges, so the gap is zero. For all outward edges are still saturated, but the incoming flow of gives a gap of . This explains exactly why the second cut of a flow network is not a minimum cut.
Cut of a flow network Created 2026-09-29 Updated 2026-10-18
A source-to-sink cut of a flow network is a partition of a set of the vertex set of a flow network, with and . Its cut capacity sums the flow network edge capacities of directed edges leaving .[ref]
Flows (author-hosted chapter preview). Graph Theory by Reinhard Diestel; Diestel, Flows, §6.2, printed p. 158: source-side partition and cut capacity
The side may contain any selection of the other vertices; its induced subgraph need not be a connected graph. For the five-edge flow network with flow network edge capacities , gives the partition of a set . Only and leave this side, so its cut capacity is . Choosing instead puts across the boundary in the incoming direction: its flow network edge capacity is excluded.
The left panel pairs a feasible flow of flow value with a cut of a flow network of cut capacity , proving that each is optimal. The right panel uses the same feasible flow but a different cut of a flow network: the outward flow is and the backward flow is , giving net flow . That cut capacity is , so it supplies a valid but less sharp bound. The dashed boundary marks a partition of a set, rather than an additional edge or a proposed route.
Flow conservation Created 2026-09-29 Updated 2026-10-18
Flow conservation requires equal total inflow and outflow at every vertex other than the source and sink:Equivalently, the divergence of a flow is zero there.[ref]
FordFulkerson.java. Algorithms, 4th edition by Robert Sedgewick and others; Sedgewick and Wayne, FordFulkerson.java, excess and isFeasible methods, lines 138–175: incoming minus outgoing amount and zero excess at nonterminal vertices
This is a steady accounting condition: an intermediate vertex neither creates the routed resource nor accumulates it. Splitting is allowed; equality between individual incoming and outgoing edges is not required. For the running flow, the equation at is , or , and at it is , or .
Capacity constraints alone do not ensure flow conservation. For instance, changing only from to keeps every edge amount within its flow network edge capacity, but leaves an excess inflow of at and an excess outflow of at . It is therefore not a feasible flow. Changing all affected edge amounts together to restores both equations and gives flow value .
Flow network Created 2026-09-24 Updated 2026-10-14
A flow network is a directed graph with distinct source and sink vertices and a nonnegative flow network edge capacity on each directed edge . In the finite setting here, every flow network edge capacity is a finite real number. A feasible flow assigns a nonnegative amount to each original directed edge, satisfies the capacity constraints, and obeys flow conservation at every other vertex:These are nonnegative arc amounts. The antisymmetric convention in flow instead records net amounts , taking a missing arc amount as zero. The two conventions express the same flow conservation; keeping them distinct makes backward residual network edges easier to interpret.
Think of vertices as routers, directed edges as communication links, flow network edge capacities as available bandwidth, and flow as a steady transmission rate. An intermediate router can distribute incoming traffic among outgoing links, but flow conservation prevents it from creating traffic. The maximum flow problem asks how much total traffic can pass from to , allowing several graph paths to share the work. The same flow network language models transportation and abstract resource allocation.[ref]
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/4064d889e5033a9915327a777d12b592_notes_flow.pdf. Goemans, Network flows, introduction and maximum flow formulation
Our running flow network has vertices and exactly five directed edges, with flow network edge capacitiesThe cross edge lets traffic entering use spare capacity on . With this edge removed, the two separate graph paths can carry only ; including it will let the maximum flow reach . Thus a link's usefulness depends on the rest of the flow network, rather than just its own flow network edge capacity.
Matrix rounding with fixed margins 2026-10-25
A matrix of nonnegative rational numbers with integer row and column sums can be rounded entrywise up or down while preserving all those sums. Let and be its floor and fractional part. The residual row and column sums and are nonnegative integers. Build a flow network with source-to-row flow network edge capacities , row-to-column flow network edge capacities one where , and column-to-sink flow network edge capacities . The fractional parts supply a feasible flow saturating all source arcs. The integral max-flow theorem supplies an integral one of the same total value. If its middle-arc flows are , with where , then is the required matrix. This is a constructive polynomial-time algorithm; no multiplication by a common denominator is required.
Max-flow min-cut theorem Created 2026-09-24 Updated 2026-10-14
For a finite flow network with finite nonnegative real flow network edge capacities, the greatest strength of a flow of a feasible flow equals the least cut capacity of a source-to-sink cut of a flow network:For a maximum flow, the vertices reachable from the source in the residual network define a minimum cut whose outgoing original edges are saturated and whose incoming original edges carry zero flow.[ref]
https://courses.csail.mit.edu/6.854/21/Notes/n06-flow.html. Karger, MIT 6.854 Notes 6, maximum-flow optimality conditions
Why is a cut of a flow network an upper bound? Sum flow conservation on its source side . Internal edge contributions cancel, leavingOnly directed edges leaving contribute to cut capacity. Directed edges entering are subtracted in net flow, so adding their capacities to the upper bound would lose the intended bottleneck. This inequality is weak duality; the theorem says the bound is attained, an instance of strong duality. Its beauty is that a routing plan and a separating boundary independently witness each other's optimality.
In the running flow network, the two internal vertices give four possible source sides. For , the cut capacity is . For it is . For it is ; the incoming edge contributes nothing to that cut capacity. Finally, gives . Thus the minimum cut has cut capacity , matching the explicitly computed maximum flow.
Maximum flow of value five and two minimum-cut certificates
. Labels show flow/capacity on each directed edge. The shaded source sides give cuts of capacities three plus two and two plus one plus two, both equal to the flow value. Details.Ford and Fulkerson's 1956 paper opens with a railway-capacity question attributed there to T. Harris and proves a minimal-cut theorem as Theorem 1. Its original formulation uses graph paths carrying nonnegative amounts; the residual reachability certificate for maximum flow below gives the finite directed flow network proof used here.[ref]
https://doi.org/10.4153/CJM-1956-045-5. Ford and Fulkerson, Maximal Flow Through a Network, Canadian Journal of Mathematics 8 (1956), pp. 399–404
Maximum flow problem Created 2026-10-05 Updated 2026-10-20
The maximum flow problem maximises the strength of a flow from a source to a sink subject to flow conservation and flow network edge capacities. For the nonnegative arc amounts used in flow network, its objective is net outflow from the source:The equality follows by summing flow conservation over all internal vertices. Incoming source flow must be subtracted: merely circulating traffic through does not deliver more to . The max-flow min-cut theorem identifies the optimum with the least cut capacity of a cut of a flow network. A feasible flow and a cut of a flow network of equal value certify optimality without requiring a particular choice of augmenting paths.
For the five-edge flow network with flow network edge capacities , takeEvery capacity constraint holds with equality. Flow conservation at is , and at it is . The strength of a flow is , also entering . This flow consists of units on the graph path , on , and on . The cut of a flow network with source side has cut capacity , so no feasible flow can do better.
Even a seemingly poor first augmenting path , carrying , does not cause failure in this example. It leaves residual network capacity along and along . These two subsequent augmenting paths yield values , , and , and produce exactly the flow above. Backward residual network edges become essential in the unit-capacity example under residual network, where this same first choice blocks every unused forward route.
Discrete assignment is another reason to study maximum flow. Put unit-capacity edges from to job vertices, from each job to eligible worker vertices, and from workers to . An integral flow selects a matching in a graph: each job and worker participates at most once, and the strength of a flow counts assigned jobs. The integral max-flow theorem therefore turns maximum cardinality assignment into maximum flow. Minimizing assignment costs is the related assignment problem, modeled by minimum-cost flow.[ref]
https://ocw.mit.edu/courses/6-854j-advanced-algorithms-fall-2008/4064d889e5033a9915327a777d12b592_notes_flow.pdf. Goemans, Network flows, assignment formulation
Past exam of the computer science course of the University of Oxford 2019 Algorithms 1 a Solution 2026-10-25
Use nonnegative amounts on the original directed edges of the flow network. A feasible flow is a function satisfying the capacity constraints and flow conservation at every internal vertex:Its flow value is net outflow at the source,Summing flow conservation shows that this is also net inflow at the sink. Subtracting incoming flow matters when the source has incoming edges.
An – cut of a flow network is a partition of a set with and . Its cut capacity is the total outward flow network edge capacity,Incoming edges do not contribute to this sum. Equivalently, one may use the antisymmetric net-flow convention, but the nonnegative arc convention above will also be used in the subsequent reductions.
Past exam of the computer science course of the University of Oxford 2019 Algorithms 1 c Solution 2026-10-25
A path-cycle matching is exactly an edge subset whose resulting subgraph has maximum degree at most two: every nontrivial connected component of a graph of this form is a graph path or a cycle in a graph. Thus the task is a bipartite b-matching problem with bound two at every vertex.
Find a bipartition , orient every original edge from to , and add a source and sink . Give each arc , for , flow network edge capacity two; each original arc flow network edge capacity one; and each arc , for , flow network edge capacity two. Compute an integral maximum flow and select the original edges whose flow is one. The integral max-flow theorem guarantees such an integral optimum.
By flow conservation, at most two selected edges touch each vertex, so they decompose into the required vertex-disjoint paths and cycles in a graph. Conversely, any permissible path-cycle matching gives a feasible flow: send one unit through its middle arc for each selected edge, with the outside arc amounts equal to the endpoint degrees. In both directions, the flow value equals the number of selected edges. Maximizing either quantity therefore maximizes the other.
The blue edges in this example form a four-cycle in a graph and a one-edge graph path; the dashed edge is unused. Their five units of flow are optimal: the two left vertices can each contribute at most two selected edges, and has only one incident edge.
The constructed flow network has vertices and arcs. A polynomial-time algorithm for maximum flow, such as the Edmonds–Karp algorithm, followed by a traversal of the selected subgraph, gives an efficient solution.
Past exam of the computer science course of the University of Oxford 2019 Algorithms 1 d Solution 2026-10-25
Separate the forced integer portion from the choice of rounding direction. Put and . Define residual demandsThese are nonnegative integers, since the original row and column sums are integers. Also . Each fractional part satisfies .
Construct a flow network with a vertex for each row and column, source-to-row arcs of flow network edge capacity , row-to-column arcs of flow network edge capacity one exactly where , and column-to-sink arcs of flow network edge capacity . The amounts themselves define a fractional feasible flow of flow value . No flow can exceed , the total source flow network edge capacity. Because all constructed flow network edge capacities are integers, an integral maximum flow also has flow value and saturates every source and sink arc.
Let be its middle-arc flow, taking when that arc is absent. Then , and the required answer isAt an already integral entry no middle arc exists, so that entry stays fixed. At a nonintegral entry the two possibilities are precisely its floor and ceiling. Flow conservation gives and , preserving every original row and column sum.
This is matrix rounding with fixed margins. There are vertices and at most arcs. Exact rational arithmetic computes the floors and residual demands in polynomial time in the encoded input length; the resulting flow network edge capacities are small integers, so there is no need to scale by a potentially large common denominator.
Past exam of the computer science course of the University of Oxford 2019 Algorithms 1 e Solution 2026-10-25
First give the vote of every voter whose allowed set contains . Let their number be . This loses no possible strict victory: starting with any winning assignment, changing such a ballot to increases 's score and weakly decreases an opponent's score. Thus a winning assignment exists exactly when one exists with these ballots fixed.
Every remaining voter must now be assigned to an allowed opponent, and each opponent may receive at most votes. If any allowed set is empty, there is no valid election assignment. With at least two candidates, immediately makes a unique victory impossible. With only the candidate , every nonempty ballot set forces that candidate, so the answer is yes under the question's strict-comparison definition.
For the remaining case , make a flow network with a vertex for each remaining voter and each opponent. Add source-to-voter arcs of flow network edge capacity one, voter-to-opponent arcs of flow network edge capacity one for the allowed choices, and opponent-to-sink arcs of flow network edge capacity . Compute an integral maximum flow. ThenA flow saturating all voter arcs assigns each remaining voter to exactly one allowed opponent, by integrality and flow conservation. The sink-arc capacity constraints give every opponent strictly fewer than votes. Conversely, any winning assignment with the fixed votes defines just such a saturating feasible flow. The flow network has at most vertices and arcs, hence the decision takes polynomial time.
The vertex separator version of Menger's theorem says that, for distinct nonadjacent vertices of a finite graph, the maximum number of internally vertex-disjoint paths from to equals the minimum size of an – vertex separator.
Use the following version of the max-flow min-cut theorem: in a finite directed flow network with nonnegative integer flow network edge capacities, the maximum flow value equals the minimum cut capacity, and a maximum flow can be chosen to have integer values on every directed edge. The last clause is the integral max-flow theorem.
Here is the reduction, including the correspondence with vertex separators. Put . Perform vertex splitting on each vertex , replacing it by with a directed edge of flow network edge capacity one. Keep as the source and as the sink. For each original undirected edge , put directed edges from the output of to the input of and from the output of to the input of , each of flow network edge capacity ; an unsplit endpoint uses or itself.
A family of internally vertex-disjoint paths gives a feasible integral flow of value , by sending one unit down each graph path. Conversely, decompose an integral flow into unit source-to-sink graph paths and directed cycles, discarding the directed cycles. This decomposition can be obtained by following positive-flow directed edges and subtracting one unit along a source-to-sink graph path or a directed cycle, repeating until the flow value is exhausted. A capacity-one split edge can belong to at most one unit graph path. The projected graph paths in are therefore internally vertex-disjoint paths. Thus the largest number of such graph paths equals the maximum flow value.
Deleting a vertex separator corresponds to removing its split edges, of total flow network edge capacity . This destroys every source-to-sink graph path; taking the source-reachable vertices after removal gives a cut of a flow network of cut capacity at most . Thus the minimum cut capacity is no greater than the minimum vertex separator size.
For the reverse inequality, deleting all internal vertices separates , because they are nonadjacent. Hence a minimum cut has cut capacity at most and cannot contain a directed edge of flow network edge capacity . Its outgoing edges are therefore split edges. Let be the original vertices associated with them. Any – graph path avoiding would lift to a source-to-sink graph path crossing this cut of a flow network without using an outgoing edge, an impossibility. Hence is a vertex separator, with size exactly the cut capacity. The two minima agree, and the max-flow min-cut theorem proves Menger's theorem.
Past exam of the mathematics course of the University of Cambridge 2002 ib Paper 4 5H Solution Created 2026-09-24 Updated 2026-10-14
Consider a finite directed flow network with source , sink , and nonnegative finite flow network edge capacities . A feasible flow assigns to each arc and satisfies flow conservation at every vertex except . Its value is net outflow from , equivalently net inflow to . A maximal flow here means a flow of greatest value, also called a maximum flow. A source–sink cut of a flow network is a partition with , ; its cut capacity is , summing directed arcs from to its complement.
The max-flow min-cut theorem statesFor any feasible flow and cut, summing flow conservation over vertices in cancels internal arcs and gives . This proves the upper bound by every cut.
For the reverse bound, a maximum exists: the feasible set is a nonempty closed subset of the bounded product , hence compact, and is continuous. Choose a maximizing flow . Its residual network has a forward arc for unused capacity and a reverse arc for cancellable flow , retaining original-arc identities if necessary. If a residual path joined to , the minimum of its positive residual capacities would be positive. Increasing forward flows and cancelling reverse flows by this amount would preserve all constraints while increasing , a contradiction.
Let consist of vertices reachable from through positive residual arcs. Then . An original arc from to must be saturated, since otherwise its forward residual arc would make its endpoint reachable. An original arc from to must carry zero flow, since a positive reverse residual arc would again extend reachability. ThusThe upper bound and this equality prove the theorem and exhibit a residual reachability certificate for maximum flow. The argument works for real capacities and does not assume that an arbitrary augmenting-path algorithm terminates in finitely many steps.
Past exam of the mathematics course of the University of Cambridge 2004 ib Paper 4 10G Solution Created 2026-09-24 Updated 2026-10-14
Take a finite directed flow network with distinct source , sink and finite nonnegative flow network edge capacities. A flow assigns to each edge with and obeys flow conservation at every vertex except . Its value is net outflow from the source, . A maximal flow here means a maximum flow: one with greatest value among feasible flows. A source-to-sink cut of a flow network is a partition with , ; its cut capacity is , counting directed edges leaving .
The max-flow min-cut theorem statesSumming conservation over cancels internal edges and givesThis is the upper bound for every flow and every cut. To prove equality, a maximum exists: the feasible edge vectors form a nonempty closed bounded subset of a finite-dimensional real space, and flow value is continuous.
For a maximum , construct its residual network. Each edge has a forward residual edge of capacity and a backward residual edge of capacity ; retain those of positive capacity. If a residual source-to-sink path existed, augment by the smallest residual capacity on that finite path. Increasing original forward flows and decreasing backward flows preserves all feasibility conditions and increases value, contradicting maximality. Thus no such augmenting path exists.
Let be the vertices reachable from in the residual network. Then . Every original edge leaving is saturated, since otherwise its positive forward residual edge would make its endpoint reachable. Every original edge entering has zero flow, since otherwise its backward residual edge would give the same contradiction. HenceTogether with the universal upper bound this proves equality and identifies a minimum cut. This proof covers real capacities without assuming that an augmenting-path algorithm terminates after finitely many steps. Merely being impossible to increase all edge flows coordinatewise is not the optimization meaning of “maximal” used in the theorem.
Past exam of the mathematics course of the University of Cambridge 2010 iii Paper 35 3 a Solution Created 2026-10-03 Updated 2026-10-14
For a finite directed flow network with source , sink and nonnegative finite flow network edge capacities , the max-flow min-cut theorem statesHere feasible arc flows satisfy and flow conservation at every vertex except . Their strength of a flow is the net outflow at . A cut of a flow network has cut capacity equal to the sum of capacities on arcs directed from to .
For any feasible flow and any such cut of a flow network, summing flow conservation over cancels internal arcs and givesThus every flow value is bounded by every cut capacity.
A maximum flow exists: the feasible arc-flow vectors form a nonempty closed subset of the finite-dimensional compact box , and flow value is continuous. Choose one, . Its residual network has a forward arc of capacity and a reverse arc of capacity for each original arc. If a residual – augmenting path existed, its smallest positive residual capacity would permit increasing forward flows and decreasing reverse flows along the path. This preserves all capacity bounds and internal flow conservation while strictly increasing , a contradiction.
Let be the vertices reachable from through positive residual arcs. Then . Every original arc leaving is saturated, since otherwise its endpoint would also be reachable. Every original arc entering carries zero flow, since a positive flow would create a residual reverse arc leaving . ThereforeTogether with the universal upper bound, this proves both optimality claims and the theorem. This existence argument works for real capacities; it does not assume that arbitrary choices in the Ford-Fulkerson algorithm terminate. For integer capacities, positive augmentations are integral and increase the flow value by at least one, so the algorithm does terminate.
Past exam of the mathematics course of the University of Cambridge 2017 ib Paper 4 20H a Solution Created 2026-09-24 Updated 2026-10-05
A finite flow network is a directed graph with distinguished source , sink , and nonnegative finite flow network edge capacities on its directed edges. A feasible flow consists of numbers satisfyingThe second condition is flow conservation; absent edges contribute zero. The strength of a flow is its net outflow from the source,which equals net inflow to the sink by summing flow conservation over the other vertices. The maximum flow problem isNo assumption that a capacity-saturating flow at the source is feasible downstream is made. On a finite network a maximum exists, because the constraints define a nonempty compact set of edge flows and the objective is continuous.
Residual network Created 2026-09-29 Updated 2026-10-14
For a feasible flow , each original directed edge supplies a forward residual network edge of capacity and a backward one of capacity ; zero-capacity residual edges may be omitted. The forward edge permits an increase, while the backward edge permits cancellation of existing flow. In particular, backward residual capacity is the amount already sent, rather than unused original capacity. If both original orientations exist, keep their residual contributions separate, or add capacities for contributions with the same direction. An augmenting path uses these permitted changes while preserving flow conservation and the capacity constraints.
To see why cancellation matters, give all five directed edges , , , , unit flow network edge capacities. Starting from zero flow, an augmenting path carrying yieldsThe remaining unused original edges are and , which do not form a source-to-sink graph path. However, the backward residual edge has capacity . Consequently the residual network contains the augmenting path , with residual capacities .
Augment by : increase and from to , and decrease from to . The result isNow flow conservation is at and at . The final flow sends one unit along each of and . The cut of a flow network has cut capacity , proving this is a maximum flow. Traversing in the residual network revised the earlier routing decision; it did not send actual traffic along a nonexistent original edge.
In a finite flow network, a maximum flow exists because the feasible flow set contains the zero flow and is a compact set: the capacity constraints bound every coordinate, and they and flow conservation define a closed set. The strength of a flow is a continuous function, so the extreme value theorem gives an attained maximum. An augmenting path in the residual network would permit positive augmentation, contradicting maximality. The source-reachable vertices in the residual network therefore define a cut of a flow network whose outgoing original edges are saturated and incoming original edges carry zero flow. Flow conservation makes the strength of a flow equal to this cut capacity, proving the max-flow min-cut theorem.
Existence and strong duality for finite real flow network edge capacities do not imply finite termination for every choice of augmenting paths in the Ford-Fulkerson algorithm. With irrational capacities, some choices can continue forever. With integer capacities, Integrality of the Ford-Fulkerson algorithm instead forces finite termination; rational capacities reduce to that case by a common denominator. Choosing shortest augmenting paths as in the Edmonds–Karp algorithm avoids dependence on capacity magnitudes.[ref]
https://courses.csail.mit.edu/6.854/21/Notes/n06-flow.html. Karger, MIT 6.854 Notes 6, section 2.1, rational and real capacities
Strength of a flow Created 2026-09-24 Updated 2026-10-18
The strength of a flow, also called its flow value, is net outflow from , equivalently net inflow to :The notation denotes this signed value, rather than an absolute value.[ref]
Flows (author-hosted chapter preview). Graph Theory by Reinhard Diestel; Diestel, Flows, §6.2, printed p. 159: total value after Proposition 6.2.1 and footnote 4 on possible negative values
The equality follows by summing the divergence of a flow over all vertices: the internal vertices contribute zero by flow conservation, while every edge cancels between its two endpoints. Hence . For the running flow, .
Net outflow matters even when the source has incoming edges. As a separate example, give , and flow network edge capacities and flow amounts . At , flow conservation reads . The source sends units along outgoing edges but receives back, so the flow value is , exactly the amount arriving at . The two-edge network circulation through raises total edge usage without increasing net delivery.



