Breadth-first search Created 2026-09-24 Updated 2026-10-14
Breadth-first search is a graph search that explores successive layers of graph distance from a starting vertex . Here the graph is an undirected graph on a finite set of vertices, and distance counts edges, with no differing edge weights. Mark as discovered, assign , and place it in a FIFO queue. Repeatedly remove the front vertex and scan its adjacency list. Whenever a graph neighbour is still undiscovered, mark it immediately, record as its parent in a rooted tree in the discovery tree, assign , and enqueue at the rear. Marking on insertion ensures that another edge cannot enqueue the same vertex again. [ref]
Use the same undirected graph as depth-first search, with vertex set and edges
where denotes the unordered pair . Start at and scan graph neighbours in lexicographic order of their one-letter labels. The diagram's generator computes the following layers and the parent in a rooted tree assigned to each discovered vertex; the source is the root of a tree and has no parent in a rooted tree.
Graph distance from Vertices in discovery orderParent in a rooted tree in the same order
none
Figure 1.
Breadth-first search: graph distance layers and two ordered FIFO queue snapshots
. Solid edges record first discovery; dashed edges are still present in the original graph. The FIFO queue contains after processing and after processing , with its front on the left. Colors encode graph distance in the graph without edge weights. Details.
The discovery and removal orders both happen to be . After processing , the FIFO queue is : must be processed before the newer . Processing then skips the already discovered and enqueues , giving . Processing adds nothing. Processing discovers , giving ; later sees already marked and leaves its parent in a rooted tree unchanged. The discovery edges are , forming a rooted tree on all seven vertices even though the original graph contains graph cycles. The discovery tree contains six edges; it need not contain every examined edge.
First arrival is shortest because the FIFO queue keeps assigned distances in nondecreasing order, with entries from at most two consecutive layers. While processing distance , newly discovered vertices receive distance and join the rear. If an undiscovered vertex had a shorter graph path, its preceding vertex on that graph path would lie in an earlier layer and would already have discovered it. Thus is the minimum number of edges from to . This is a mathematical induction over the layers, not an assumption about the drawing. Following the parent in a rooted tree backwards at each step gives ; reverse that sequence to obtain the three-edge graph path . is another shortest graph path, but the specified graph neighbour order makes discover first. Changing that order can change the parent in a rooted tree without changing graph distances. [ref]
The shortest-route guarantee concerns the shortest path problem measured by edge count. It also minimizes total cost when every edge has the same positive cost. With unequal edge weights, first discovery need not minimize total cost; nonnegative costs can instead be handled by the Dijkstra algorithm. Breadth-first search is useful for minimum-hop routes and for finding all vertices within a specified graph distance. Its FIFO queue finishes an older layer before the next one, whereas depth-first search uses a call stack or explicit LIFO stack to pursue one branch immediately.
With adjacency lists and constant-cost discovery checks, together with constant worst-case or amortized analysis cost for FIFO queue insertion and removal, the time complexity is in Big O notation. Every reached vertex is enqueued and removed once, each incident edge is scanned at most twice in an undirected graph, and initializing all marks and distances takes . The FIFO queue contains at most vertices; the example's maximum is three. Discovery marks, distances and the recorded parent in a rooted tree for each nonroot vertex also give auxiliary space complexity, excluding the graph. An array that shifts every entry on front removal can lose the linear time complexity; the FIFO queue abstraction alone does not make removal constant-cost. Ordering the adjacency lists is a separate preprocessing cost.
A single start reaches only its connected component of a graph. Unreached vertices retain distance and have no recorded parent in a rooted tree. Restarting at each still-undiscovered vertex, while preserving all discovery marks, produces a forest covering the graph; each new root of a tree gets distance zero, so these distances refer to that root of a tree, not to the original .
Depth-first search 2026-10-13
Depth-first search is a graph search that follows a branch as far as it can before returning to try the next unexplored branch. Starting at a vertex of an undirected graph on a finite set of vertices, mark as discovered. Scan its graph neighbours in a fixed order: for each undiscovered vertex, record the current vertex as its parent in a rooted tree in the discovery tree, mark the new vertex, and explore it immediately using recursion. Return when its adjacency list is exhausted. Discovery marks persist after return, preventing a graph cycle from causing repeated exploration. This branch-and-return rule is the maze exploration described in MIT's notes. [ref]
Use the same unweighted undirected graph as breadth-first search, with vertex set and edges
where denotes the unordered pair . Visit graph neighbours in lexicographic order of their one-letter labels, starting at . The discovery order, computed by the diagram's generator, is
The discovery edges in order are . They form a rooted tree spanning the reached vertices, with root of a tree . The other edges, and , remain in the original graph but never discover a new vertex. In particular, the graph cycle causes no repeated discovery.
Figure 1.
Depth-first search: discovery edges and the active call stack on seven vertices
. Numbers show first-discovery order. Solid edges form the discovery tree; dashed edges belong only to the original graph. The right panel shows the call stack from oldest call to current call, including the return from before entering . Details.
At there is no undiscovered graph neighbour, so its call returns to . The next call enters , then , then , then . Immediately after discovering , the call stack is , with on top; is still discovered but its call has finished. The maximum call stack depth is six, although seven vertices are discovered. Following the recorded parent in a rooted tree backwards at each step reconstructs a graph path; here the route from to is , using five edges. Breadth-first search instead finds , using three edges. Depth-first search establishes reachability but does not guarantee the fewest edges.
An explicit LIFO stack can replace recursion, but its entries and discovery rule must be specified. To reproduce this exact traversal, store one frame per active vertex, retaining the next position in its adjacency list. Advance the top frame by one graph neighbour; if that vertex is undiscovered, mark it and push its frame immediately; pop an exhausted frame. Pushing all undiscovered graph neighbours at once and marking them on push is a different iterative variant. Even pushing them in reverse lexicographic order does not generally reproduce the parent in a rooted tree relationships above: would already be marked while processing , so could not discover .
With an adjacency list representation, constant-cost discovery checks and frame operations, and the graph neighbours already ordered, depth-first search has time complexity in Big O notation. Each reached vertex is entered once and each incident edge is examined at most twice in an undirected graph; initializing all discovery marks costs . The call stack has depth at most , since no active vertex repeats. Discovery marks and the recorded parent in a rooted tree for each nonroot vertex also need auxiliary space complexity, excluding storage for the graph. Sorting adjacency lists to obtain a chosen order is additional work. [ref]
One start explores only its connected component of a graph. To cover a disconnected graph, start again at every still-undiscovered vertex while keeping all discovery marks; the discovery trees form a forest. Depth-first search is useful for reachability, constructing a spanning tree of a connected graph, and organizing the return steps needed by a depth-first traversal of a tree. For detecting a graph cycle in a simple graph that is an undirected graph, an edge to an already discovered vertex other than the current parent in a rooted tree closes a graph cycle; the immediate return edge to that parent in a rooted tree is not itself a graph cycle.
// Target: computer-science.bigb
DFS discovery time 2026-10-14
The DFS discovery time of a vertex is its first-visit number in depth-first search, assigned by an increasing counter. Discovery edges form a rooted tree in each connected component of a graph. For the joined- example, starting at and visiting graph neighbours in lexicographic order gives first visits , numbered ; its discovery edges are . These numbers encode the chosen traversal, not an invariant of the graph.
Let be disjoint, equally sized, nonempty sets, with . Suppose an intersecting family is unchanged by all such UV-compressions of smaller size. Then its -UV-compression is still an intersecting family. Indeed, a newly moved member can only be disjoint from a retained old member , since two newly moved members share . Here and . If , retaining forces to have been present, contradicting the old intersection property with . Otherwise choose with and . Stability under the smaller -UV-compression forces to be present; this member is disjoint from , again a contradiction. Repeatedly applying a changing UV-compression of smallest size terminates, since the sum of lexicographic order positions decreases. A terminal set family is a lexicographic initial segment: a missing earlier member and present later member would be moved by , .
For , the Erdős-Ko-Rado theorem bounds an intersecting family by the displayed size. The first that many rank- sets in lexicographic order all contain coordinate one. Therefore the lexicographic initial segment of the same size as any intersecting family is also intersecting. This statement concerns ordinary one-element intersection and does not extend to higher intersection requirements.
Give the lexicographic order and the order topology. Every point has an interval neighbourhood between and , lying entirely in the vertical line . These intervals give each such line its usual real topology, and every line is open. Thus this space is a disjoint union of uncountably many open copies of the real line and is not a second-countable space: any basis of a topology must supply a different member inside each of these disjoint nonempty open sets.
On eight points, the rank-four Frankl family consisting of sets containing at least three of has seventeen members and is two-intersecting. The first fifteen rank-four sets in lexicographic order contain , while the sixteenth is . The earlier set meets it only at one. This disproves preservation of two-intersection by lexicographic replacement even when the rank is half the ground-set size.
For a coalition , its coalition excess at an allocation is , measuring its complaint. Sort all these excesses of a coalition in decreasing order. The nucleolus is the imputation whose sorted vector is smallest in lexicographic order: minimize the greatest complaint first, then the next among ties, and continue. Including the empty and grand coalitions merely inserts two fixed zero entries and does not change the minimizing allocation.
For every efficient allocation, the excesses of a coalition of and sum to zero:
The largest proper-coalition coalition excess is therefore at least zero. Since the core of a cooperative game from part (b) is nonempty, this first-stage minimum is exactly zero and its minimizers are precisely that core of a cooperative game. Restrict to , . The six proper-coalition excesses of a coalition are
The two zero excesses of a coalition are fixed. Among the remaining excesses of a coalition, , so the next largest complaint is . It is minimized by equalizing those two affine expressions:
This minimizer is unique, so later lexicographic stages cannot change it. Thus
Its sorted proper-coalition coalition excess vector is . The calculation both identifies the nucleolus and proves uniqueness for this game without replacing the requested computation by the general uniqueness theorem.
The lexicographic order is a total order. Each point lies in the order interval between and , so the order intervals cover .
If lies in both and , let and in that total order. Then and
In particular an order interval contains and is contained in the intersection. Both conditions of part (a) hold, proving that these intervals form a basis of a topology. The resulting topology is the lexicographic order topology on the real plane.
The Ohnishi orderability criterion states that, for each finite list , there are signs such that the semigroup of nonempty products of conjugates of does not contain . The conjugates are essential for a two-sided invariant total order. Necessity follows by choosing all signed elements positive: their conjugates and nonempty products are still positive.
For sufficiency, consider the compact product . Impose the closed conditions that an inverse has the opposite sign, that conjugation preserves sign, and that a product of two positive elements is positive whenever it is nonidentity. A positive pair cannot multiply to the identity because of the inverse condition. Each condition uses finitely many coordinates. Given finitely many conditions, collect every nonidentity element appearing in them into a finite list and choose signs using the criterion. These signs satisfy the conditions: an incorrectly negative product would contribute its positive inverse to the generated semigroup, producing identity with the positive factors; an incorrect conjugate or inverse gives the same contradiction. Extend the signs arbitrarily to the remaining coordinates. Thus the finite intersection property and compactness give a global sign assignment. Its positive elements form a conjugation-invariant semigroup with and . Defining by gives the required linearly ordered group.
Restriction shows that every finitely generated subgroup of an orderable group is orderable. Conversely, suppose every such subgroup is orderable. If the criterion failed on , each of the finitely many sign choices would have an identity witness made of finitely many conjugates. Collect all and all conjugating elements in these witnesses into one finitely generated subgroup . An order on supplies one positive sign choice, but its corresponding witness is a nonempty product of positive elements in , a contradiction. Hence the criterion holds in .
Finally, a finitely generated subgroup of a torsion-free abelian group is by the Fundamental theorem of finitely generated abelian groups. Its lexicographic order is two-sided invariant. Applying the local-to-global conclusion proves that every torsion-free abelian group admits the required order.
Identify the vertices of the Boolean hypercube with subsets of . Write for the closed vertex neighbourhood and for the external vertex boundary. The cube order used here is the simplicial order on the discrete cube: increasing size, then lexicographic order, with the smallest differing coordinate belonging to the earlier set. We prove Harper theorem by induction on ; subtracting the common size of the families converts a closed-neighbourhood comparison into the required boundary comparison.
First, the closed neighbourhood of a simplicial initial segment is itself an initial segment. Such a family consists of full lower levels and a lexicographic initial part of its last level. Its next-level neighbours form the upper shadow of that part. For a set in the next level, its lexicographically earliest lower-level subset is obtained by deleting its largest element. This map preserves the lexicographic order weakly. Membership in the upper shadow is equivalent to that earliest subset belonging to the original initial part, so the upper shadow is an initial part too. Empty and full families satisfy the assertion directly.
Assume the theorem in dimension . Split into two sections according to membership of coordinate , deleting from the second section. Their closed-neighbourhood sections are
Replace each section by a simplicial initial segment of the same size. Induction gives . By the preceding observation, each is an initial segment and is nested with the other section. Consequently
and the analogous inequality holds for the other section. Thus simplicial section compression preserves size and cannot increase the closed neighbourhood.
Repeatedly apply a nontrivial section compression. The sum of the positions of the family members in the full simplicial order strictly decreases: the order induced on either fixed-coordinate section is precisely its lower-dimensional simplicial order. This positive integer potential makes the process terminate at a family fixed by every section compression.
We classify such terminal families for simplicial section compression. If an earlier vertex is absent while a later vertex is present, they cannot agree at any coordinate, since the corresponding section is an initial segment. Hence . Every other vertex earlier than is present, and every other vertex later than is absent, since any further inverted pair would also have to be complementary. There can therefore be no vertex strictly between and . Thus either is an initial segment or is an initial segment with its last vertex replaced by the next, complementary vertex.
The complementary consecutive pairs are explicit. If , the ranks must be and , and consecutive order positions force
The corresponding initial segment contains all sets of size at most , and . Its closed neighbourhood contains all sets of size at most : for , deletion of just one -set cannot remove all the -subsets of any -set, and remains adjacent to one of its -subsets. In addition, the supersets of of size enter the neighbourhood. Thus ; the case gives equality directly.
If , the two vertices have rank . Complementation reverses the lexicographic order within that rank, so consecutive complements occupy its middle two positions. These are
Now contains all sets of size less than and all -sets containing coordinate one. Its closed neighbourhood contains all sets of size at most and all -sets containing one. For , each such -set has at least two -subsets containing one, so exchanging for loses none of these neighbours. It adds the supersets of of size that avoid one. Hence . For the two neighbourhoods are both the entire cube.
In both exceptional cases the initial segment has no larger neighbourhood. The induction starts with the one-vertex zero-dimensional cube, and the compression argument now proves
For a transferable utility game, the characteristic function of a coalitional game assigns a coalition its largest total attainable revenue , with . The core of a cooperative game consists of payoff vectors satisfying efficiency, , and coalition stability, for every . A coalition receiving less could operate alone and distribute its extra value to make each member better off.
Use thousands of pounds as the monetary unit. The physical directed arcs are and , owned by , with capacities ; and , owned by , with capacities ; and , owned by , with capacity .
Figure 1.
Company ownership and capacities in the two-demand communication network
. Details.
The physical network is acyclic. There are exactly three – graph paths and one – graph path. Let be the – flows on , , , respectively, and let be the direct – demand. Their capacities and revenue are
Every feasible traffic pattern decomposes into these graph paths, so these inequalities are exact. The first is redundant, since and imply it.
Formulate this as a minimum-cost flow through the two-resource path packing as minimum-cost circulation reduction. Use auxiliary vertices and the following arcs, whose entries are (capacity, cost):
The first forward graph path carries , carries , carries , and carries . Conservation at imposes , and at imposes ; the individual finite-capacity arcs give the other bounds. The return arc closes the circulation. Its cost is exactly , so this is an ordinary minimum-cost circulation with precisely the required feasible traffic set. Unlimited capacities may all be replaced by , the maximum possible total graph path flow.
An linear programming optimality certificate is particularly short:
The feasible choice attains equality. Thus the actual traffic is three units from to and one from to , and
All four positive terms in the bound must be tight at any optimum, so these graph path amounts are unique.
The two traffic demands must retain their identities. Merely adding fictitious return arcs and to the physical graph can create an invalid graph cycle combining both rewards: would credit the -only network with revenue even though it carries neither requested demand. The resource-flow formulation above avoids that problem.
For the characteristic function, only complete physical graph paths owned by a coalition are available. Company or alone has no requested graph path; company carries two units of – traffic. The pair carries one unit on each of ; the pair sends two units on rather than selling them at the lower – rate; and has only the two direct – units. Therefore
Writing payments in thousands, all stable divisions of the revenue are exactly
Equivalently, , and . This is the entire core, not just one acceptable allocation.
The nucleolus minimizes in lexicographic order the sorted decreasing excesses of a coalition over imputations. Empty and grand-coalition coalition excesses are fixed zeros and can be omitted. For the six other coalitions, efficiency gives
The two -related coalition excesses sum to , so their maximum is at least . This bound is attainable, and attaining it forces . All six coalition excesses are then at most precisely when and . The fixed pair of coalition excesses equals throughout these first-stage minimizers.
Minimize the largest of the remaining coalition excesses. They become , whose maximum is . Its unique minimum is at . Hence and . The sorted proper coalition excesses there are , and
Identify the discrete cube with the subsets of , with hypercube graph adjacency given by changing one element. Write for the closed graph neighbourhood and for the external vertex boundary. The simplicial order on the discrete cube first orders by set size and then by lexicographic order, with the smallest differing coordinate belonging to the earlier set.
Harper theorem states that, for every set family ,
Here is the simplicial section compression proof. Induct on , the one-dimensional case being immediate. Split by a coordinate into sections . Its neighbourhood sections are
Replace by equally large simplicial initial segments . By induction . Also the neighbourhood of a simplicial initial segment is itself a simplicial initial segment: at its last occupied level the extra vertices form the upper shadow of a lexicographic initial segment, again lexicographically initial. Consequently the compressed unions have sizes and , no larger than the original unions. The compression preserves and cannot increase .
Repeat in every coordinate until all sections are initial. Every nontrivial compression strictly decreases the sum of the global simplicial positions, so the process terminates. To describe the terminal families for simplicial section compression, suppose an earlier absent vertex precedes a later present vertex . They cannot share a coordinate value: otherwise they lie in the same compressed section, contradicting its initiality. Thus . No vertex can lie strictly between them in the order, since it would make another absent/present pair that is not complementary. Hence the terminal family is either or that segment with its last vertex exchanged for its immediate complementary successor .
For odd , that exceptional exchange crosses the middle levels: and . For , all sets of size at most remain in the neighbourhood after the exchange, since an -set has at least two lower neighbours and only one was removed. The new can only add vertices of size .
For even , the only consecutive complementary pair in one level is and . The original segment contains all sets below size and all -sets containing 1. For , its neighbourhood contains all sets of size at most and all -sets containing 1; every such upper set still has an included lower neighbour after the single removal. The new can only add further neighbours. The cases follow directly, with the exceptional families related to the initial ones by a graph automorphism. Thus neither exception improves the neighbourhood, completing the induction.
For the half-cube vertex-boundary extrema, if , the initial half cube is all sets of size at most ; its boundary is the next level, of size . If , it contains all levels below and the -sets containing 1. The boundary consists of the -sets avoiding 1 and the -sets containing 1, giving .
No boundary can exceed the vertices outside a half cube. Taking all vertices of even Hamming weight attains that bound, because every odd-weight vertex is adjacent to one of them. Therefore, for ,
False in general. Take , , and
It is a Frankl family with members. Two members each use at least three of the first four points, so they share at least two of those points. Hence it is t-intersecting with , and .
The first fifteen rank-four sets in lexicographic order are precisely those containing . The sixteenth is , which intersects the earlier set only at one. Therefore the lex initial segment of size seventeen is not two-intersecting. This proves that lexicographic replacement can destroy two-intersection; an ordinary intersecting bound cannot justify preservation of higher-order intersection.
Always true, for the ordinary positive-rank intersecting-family convention. The Erdős-Ko-Rado theorem bounds the family's size by . In lexicographic order, the first exactly that many rank- sets are all those containing one. Therefore the initial segment of the given size is contained in that star and any two members intersect at one. This proves that lexicographic initial segments preserve ordinary intersection. Empty families cause no exception. If rank zero is admitted, its layer has just one set and replacement by either initial segment changes nothing, so all three preservation assertions at that rank hold trivially.
Identify the hypercube graph with subsets of , adjacent when they differ by one element. Write for a family's closed vertex neighbourhood. The simplicial order on the discrete cube orders first by size and then, within a rank, by lexicographic order: the least element of a symmetric difference belongs to the earlier set. The Harper theorem says that if is the initial simplicial segment with , then
Equivalently this minimizes the external vertex boundary at fixed cardinality. This is the vertex-isoperimetric assertion, distinct from the edge version in Question 3.
Here is the deduction of Kruskal-Katona theorem. For a family , adjoin every lower rank and set . For ,
The corresponding simplicial initial segment is , where is the rank- lexicographic initial segment of size . Canceling the common lower-rank count in Harper's inequality gives . The rank-zero case is immediate by considering its two possible families.
To turn upper shadows into lower shadows, let and . This bijection reverses inclusion and changes rank to . If precedes in lex order, the largest element of belongs to , so precedes in colexicographic order. Also . Hence applying the upper-shadow conclusion to the transformed family proves
where is the colex initial segment of the same size and rank as . This is the Kruskal-Katona lower-shadow theorem. A colex segment's shadow is itself a colex segment: split its sets by their largest element, giving a full initial block of the preceding ground set followed by an initial block with the new largest element. The same description holds one rank lower. Iteration therefore shows that colex segments minimize shadows at every lower rank. This proves the Harper theorem implies the Kruskal-Katona theorem deduction, including the necessary complement and coordinate reversal.
The Erdős-Ko-Rado theorem states that for , every intersecting family satisfies
The family of all -sets containing a fixed point attains the bound. We use the standard convention of positive ranks here.
For the first proof, let be the complements of members of , at rank , and let be its rank- lower shadow. It is disjoint from , since would make two family members disjoint. Suppose . The colex rank- segment of that size contains every -set on and at least one set containing . Its rank- shadow therefore contains all old -sets and at least one new -set containing . The iterated Kruskal-Katona bound gives
Then , impossible for disjoint subfamilies of rank . This proves the Erdős-Ko-Rado theorem from shadows.
For the second proof use the Katona circle method. In any cyclic ordering of the points, an intersecting collection of length- intervals has at most members. To prove this, rotate one selected interval to end at position , so it occupies . Intervals ending at miss it and cannot be selected. Among the remaining endpoints other than , pair with for . The two intervals in each pair are disjoint because , so at most one can be selected. Including the fixed interval gives at most .
Now count pairs consisting of a family member and a permutation in which it is a cyclic interval. A fixed -set has such permutations: choose its final position, its internal order, and the order of the remaining points. Each of the permutations contributes at most family intervals by the proved cyclic interval intersection bound. Thus
This is the required cyclic-ordering proof, with its interval lemma established explicitly.
The Erdős-Ko-Rado theorem asserts that, for , every intersecting family satisfies
The bound is attained by the set family of all -subsets containing one prescribed point. Here lexicographic order means that when the smallest element of their symmetric difference belongs to .
The first members in lexicographic order are exactly those containing . An initial segment longer than contains all of them and also the first member avoiding , namely . There is an -subset containing and disjoint from : choose its other elements from , which has elements. Consequently any longer lexicographic initial segment fails to be an intersecting family. Thus preservation of the intersection property upon replacing a set family by the equally large lexicographic initial segment proves the displayed bound.
Here is a direct UV-compression proof of that preservation statement. For disjoint nonempty sets with and , an eligible member contains and misses ; its proposed image is . The UV-compression moves to only if is not already present. Each eligible pair is either kept as a pair or moved from its later to its earlier member, so this operation preserves cardinality and uniformity and strictly decreases the sum of lexicographic order positions whenever it changes the set family.
The essential intersection-preserving lexicographic UV-compression lemma is that this operation preserves an intersecting family whenever all smaller lexicographically improving UV-compressions already leave that set family unchanged. Suppose instead that the compressed set family has disjoint members. At least one, say , must be newly moved. Both newly moved members would contain , so the other, , is a retained old member. Write for the old preimage. Since , we have and . Old intersectingness forces
If , then was eligible for the same UV-compression. Since it was retained, was already present. But , contradicting old intersectingness.
Otherwise . Choose with and . This is a smaller improving pair, since . The old member is eligible for its UV-compression. The assumed stability therefore forces to be present already. Yet its portion outside misses , its remaining portion misses , and misses . Thus , the required contradiction. This proves the lemma, including the size-one case, where only the first alternative can arise.
Starting with , repeatedly choose a changing improving UV-compression with the smallest possible . The lemma applies at each step because every smaller improving UV-compression is then unchanged. Thus every intermediate set family is intersecting. The strictly decreasing nonnegative integer sum of lexicographic order positions ensures termination. If the terminal set family were not an initial segment, there would be a missing earlier than a present . Taking and gives equally sized nonempty disjoint sets with , and moves to the missing . That contradicts termination. The terminal set family is therefore exactly the equally large lexicographic initial segment, and it is intersecting. This proves the required lexicographic statement directly, and hence the Erdős-Ko-Rado theorem.