Bipartite graph Created 2026-09-24 Updated 2026-10-14
A bipartite graph separates its vertices into two independent sets: every edge goes from one part to the other. Here is a finite simple graph and an undirected graph, with no self-loops and no repeated edges. The two parts satisfy
Thus neither part contains an edge. The parts need not have equal sizes, and some pairs across them may have no edge; requiring every cross pair gives a complete bipartite graph. The independent set and cross-edge definitions are equivalent.[ref]
For example, the six-vertex cycle graph with edges has parts and . Drawing the same graph as a hexagon or in two columns changes neither its edges nor its bipartite property. An extra isolated vertex can go in either part.
Figure 1.
The same six-cycle and isolated vertex drawn as a cycle and as two independent parts
. Details.
We allow either part to be empty. Consequently a graph with no edges is bipartite, even when ; choose , . Here "two colours" means two colours are available, with no requirement to use both. This convention explicitly includes the empty case, whereas definitions requiring two nonempty classes need an exception. For several connected components of a graph, choose the two parts separately in each graph component and take their unions. In a nonempty connected graph that is bipartite, fixing one vertex's colour forces all others along graph paths, so its two-colour assignment is unique up to swapping the colours. Each graph component, including an isolated vertex, can be swapped independently.
The two-colourability criterion for bipartite graphs identifies these parts with the colour classes of a proper vertex colouring: assign colour to and colour to , so adjacent vertices have different colours. More surprisingly, the odd-cycle characterization of bipartite graphs turns a global requirement into one precise obstruction:
This statement is for the finite undirected graph and simple graph model above; a graph cycle has distinct vertices except for the repeated starting vertex. Along a graph cycle in a bipartite graph, colours alternate, so returning to the starting colour takes an even number of edges. Therefore any odd cycle, whether or not other edges join its vertices, prevents a bipartite split.[ref]
Breadth-first search supplies the converse constructively. Start an uncoloured vertex with colour , and use a FIFO queue to explore its graph component. When an edge first discovers , give the opposite colour to , record as its parent in a rooted tree, and enqueue . If both endpoints of any scanned edge already have the same colour, stop with a conflict. Restart from an uncoloured vertex until every graph component has been examined. If no conflict occurs, all edges cross the two colour classes, which are the required independent sets.[ref]
A conflict also explains the failure. In the rooted tree produced by breadth-first search, let be the graph distance from . The colour of is its distance's integer parity. An edge in an undirected graph satisfies , so equal colours force . Follow the two parent chains upward to their lowest common ancestor , discard the shared graph path from to , and join the remaining two graph paths with the conflict edge . The result is a genuine graph cycle with
edges, an odd integer. The two branches have no shared vertices except , so this is more than a closed walk. This odd cycle is a certificate that anyone can check directly, using only its listed vertices and edges.
Figure 2.
A BFS colour conflict closes a five-cycle; the shared root path is excluded from the certificate
. Details.
In the example, breadth-first search from gives , , and . The conflict edge closes the odd cycle , with five edges. The common edge is excluded. Thus the same procedure returns either two independent sets covering , or an explicit odd cycle. With adjacency lists and constant-time FIFO queue operations, its time complexity is in Big O notation, with additional storage.[ref]
The two parts often have a practical meaning: workers and jobs, with an edge exactly when a worker can perform a job. A matching in a graph chooses compatible worker–job pairs with no reused endpoint; merely being bipartite does not guarantee enough compatible pairs. Hall's marriage theorem characterizes when every worker can be matched, and the assignment problem adds costs to seek an optimal assignment. These connections make the bipartite structure useful after recognition, as the starting point for selecting edges under constraints.
Homeomorphic embedding of a rooted tree Created 2026-10-06 Updated 2026-10-07
For finite rooted trees in the ancestor partial order, a rooted-tree homeomorphic embedding is an injective vertex map preserving lowest common ancestors: . The image of the source root need not be the host root. Edge paths and branching are preserved, while paths may be subdivided in the larger tree.
Lowest common ancestor 2026-10-06
The lowest common ancestor of two vertices is the common ancestor farthest from the root. In the ancestor partial order with the root least, it is their infimum, also called their greatest common ancestor.
We prove the labelled version of Kruskal's tree theorem, with labels in a well-quasi-ordering ; the unlabelled result is its one-label case. A label-monotone tree embedding is an injective map of finite rooted trees preserving lowest common ancestors and increasing labels. Its root may map below the host root, and an edge may map to a path. These conventions distinguish rooted-tree homeomorphic embedding from the stricter adjacency-preserving relation, which is not well-quasi-ordered.
We will use two elementary consequences of well-quasi-ordering. Every infinite sequence in a well-quasi-ordering has an infinite nondecreasing subsequence: color pairs by whether the earlier element precedes the later one, apply Ramsey's theorem, and exclude an all-bad infinite set. Restricting successively in each coordinate proves finite product closure of well-quasi-orderings.
For completeness, here is the required proof of Higman's lemma. If finite words over admitted a bad sequence, choose one whose next word always has the least length admitting a bad continuation of the fixed prefix. No word is empty. Write , separating the last letter. The set of prefixes is a well-quasi-ordering. Otherwise select a bad sequence of these prefixes with strictly increasing owner indices ; this is possible because every finite initial set of owners supplies only finitely many prefixes, and a bad sequence cannot repeat a word. Then
is bad. An earlier original word embedding into would also embed into , contradicting the original badness; comparisons inside the new tail are excluded by its choice. But is shorter than , contradicting minimality. Since the prefixes and the last letters are well-quasi-ordered, their product gives with embedding into and . Appending the matched last letters embeds into , the final contradiction. Thus finite words over a WQO are WQO.
Now suppose labelled finite rooted trees admit a bad sequence . Choose it minimally in vertex count at each successive position. Let be all immediate child subtrees of its members. This is a well-quasi-ordering: if not, select a bad sequence of child subtrees with increasing owner indices , and splice it after . Every child subtree embeds into its owner, so a comparison from the prefix to the tail would contradict original badness. The splice is bad and its first replacement is strictly smaller, contradicting the minimal bad sequence choice.
For each , list its child subtrees in any order as a finite word over and record its root label . The product is a well-quasi-ordering by Higman's lemma. Hence some has and a subsequence embedding of into . Match the roots and use the chosen subtree embeddings in distinct target branches. Their union preserves lowest common ancestors and labels, and stretches only edge paths. Thus embeds into , a contradiction. We have proved
To deduce Friedman's finite form of Kruskal's theorem, fix . At position permit unlabelled trees of at most vertices. Up to isomorphism only finitely many trees are possible at each position. Form the finite bad-sequence tree whose nodes are finite bad sequences satisfying these bounds, ordered by extension. It is finitely branching. If there were arbitrarily long admissible bad sequences, König infinity lemma would give an infinite branch, contradicting Kruskal's tree theorem. Therefore
One can instead use a fixed finite set of labels, giving a correspondingly parameterized finite statement by exactly the same proof. The crucial feature is a uniform bound for each initial size allowance, not merely termination of one chosen sequence.
For finite rooted trees, use rooted-tree homeomorphic embedding: an injective vertex map preserves ancestors and lowest common ancestors, so edges may become paths and distinct branches remain distinct. The root can map to a vertex below the host root. More generally label vertices in a well-quasi-ordering and require each source label to precede its image label. We prove this stronger labelled version of Kruskal's tree theorem, from which the unlabelled result follows by taking one label.
We first need the finite-word closure, and prove it rather than merely invoking Higman lemma. If finite words over were not a well-quasi-ordering under order-preserving subsequence embedding with increased labels, choose a minimal bad sequence , minimizing the length of among words admitting a bad continuation of the already chosen prefix. No is empty. Write by removing its last letter. The perfect subsequence lemma gives with for .
The sequence is still bad. An earlier embedding into a later would embed into , contradicting the original sequence. An embedding of into extends by the last-letter comparison to an embedding of into . Both possibilities are excluded. This contradicts minimality at position , since is shorter. Thus the finite-word closure holds. The perfect subsequence lemma also proves finite product closure: first pass to a nondecreasing subsequence in one coordinate, then in the next, preserving all previous comparisons.
Suppose now that the labelled trees admit a bad sequence . Choose a minimal bad sequence by vertex number. Let be all the proper descendant-rooted subtrees of these trees. We claim that is a well-quasi-ordering. If it had a bad sequence of subtrees , its parent indices can be made strictly increasing, say comes from . Indeed each finite initial collection of parent trees has only finitely many subtrees, and a bad sequence cannot contain infinitely many terms from a finite collection. Passing to a subsequence therefore makes .
Then is bad. A prefix tree embedding into would embed into its parent , contrary to the original badness, and the tail is bad by construction. But has fewer vertices than , contradicting minimality. This proves the claim.
Give the children of each root any fixed order. Its forest of child subtrees is a finite word in . The word theorem and finite product closure show that the pairs consisting of the root label and the child-subtree word are a well-quasi-ordering. Thus some have comparable root labels and an embedding of the child word of into that of . Map the source root to the target root and use the obtained embeddings inside distinct target child subtrees. The paths from the target root into those distinct branches are disjoint except at the root, so this is a label-monotone tree embedding. It contradicts badness. Hence
For Friedman's finite form of Kruskal's theorem, fix . There is such that any trees with contain with . Use indices starting at zero; shifting them only changes . To prove this uniform finite bound, form the finite bad-sequence tree of finite bad prefixes obeying the size bounds. At position there are only finitely many rooted-tree isomorphism types with at most vertices, so every node has finitely many successors.
If no bound existed, this tree would have nodes of arbitrarily large depth. A node with arbitrarily long extensions has a child with arbitrarily long extensions, since it has only finitely many children. Choosing such a child repeatedly produces an infinite branch, as in the König infinity lemma. The branch is an infinite bad tree sequence, contradicting the theorem just proved. Therefore the required exists. The same proof works with any fixed finite label alphabet and any specified size bound finite at each position.
Use the rooted-tree homeomorphic embedding relation: an injective map of vertices preserves lowest common ancestors, so edges may become paths and the source root may map below the target root. We prove the stronger labelled statement for labels in any well-quasi-ordering , with labels increasing under the embedding. Forgetting labels gives Kruskal's tree theorem.
First every infinite sequence in a well-quasi-ordering has an infinite nondecreasing subsequence. Colour its index pairs according as the earlier term is or is not below the later term. Ramsey's theorem gives an infinite constant-colour subsequence; the bad colour would contradict well-quasi-ordering. Applying this successively in each coordinate proves finite product closure of well-quasi-orderings.
We need Higman lemma with its proof. Order finite words over by subsequence embedding with increased letters. If there were a bad sequence, choose one minimally: at each position choose a shortest word admitting a bad continuation of the fixed prefix. No word is empty. Write , separating the last letter, and choose with . Consider
An earlier prefix word cannot embed in a later , since it would then embed in . Nor can embed in : adding the comparable last letters would embed in . Thus the displayed sequence is bad, contradicting minimality at , since is shorter. Finite words over a well-quasi-order are well-quasi-ordered.
Now suppose labelled rooted trees admit a bad sequence , chosen minimally in vertex count at each position. Let consist of all proper rooted subtrees of these trees, rooted at a descendant and containing all its descendants. We claim is well-quasi-ordered. Otherwise take a bad sequence from . Only finitely many subtrees come from any fixed finite prefix of the 's, and a bad sequence cannot repeat an object. Thin it so that comes from with . The sequence
is bad: would imply , since a rooted subtree embeds in its host; comparisons within the 's are excluded by their choice. But is strictly smaller than , contradicting minimality. This proves the claim.
Choose an arbitrary ordering of the children of each . Record its root label and the finite word of rooted child-subtrees:
By Higman lemma and finite product closure, two records, with indices , are comparable. Map the root of to the root of , and map its selected child-subtrees into the distinct selected branches of . Within a branch the embeddings preserve lowest common ancestors; between different branches both lowest common ancestors are the roots. Labels increase everywhere. This gives , contradicting badness. Finite labelled rooted trees are well-quasi-ordered by label-monotone homeomorphic embedding. In particular, this proves the unlabelled theorem. A root-preserving variant follows by giving the root a special incomparable label unavailable at nonroot vertices; the general labelled theorem then forces root to root. Adjacency-preserving embeddings are a different, more restrictive relation and do not satisfy the same assertion.
For Friedman's finite form of Kruskal's theorem, fix and consider finite bad sequences satisfying , with indices starting at . Their prefixes form a finite bad-sequence tree. At each depth there are only finitely many possible unlabelled tree isomorphism types below the size bound, so this tree is finitely branching. If bad sequences existed at every finite length, König infinity lemma would yield an infinite branch, hence an infinite bad sequence of rooted trees, contrary to what was just proved. Therefore
The same proof works with any fixed finite label set. The finite size bounds are what make the bad-prefix tree finitely branching; the proof does not claim a small effective numerical bound.
A well-quasi-ordering is a preorder in which every infinite sequence has with . A sequence without such a pair is a bad sequence. We use rooted-tree homeomorphic embedding: an injective map of vertices preserving lowest common ancestors, so edges may become paths and a source root may map below the host root. Labels, when present, must increase in their label preorder. This convention is important; adjacency-preserving embeddings do not give the same theorem.
We first prove the auxiliary Higman lemma. If is a well-quasi-order, its finite words are well-quasi-ordered by subsequence embedding with increased letters. Suppose not, and choose a minimal bad sequence of words: at each position choose one of least length among those permitting a bad continuation of the preceding prefix. No word is empty. Write by deleting its last letter. A well-quasi-order has an infinite nondecreasing subsequence of any sequence: if no member of an infinite subsequence had infinitely many later upper bounds within it, one could recursively avoid the finitely many upper bounds of earlier choices and construct a bad sequence. Choose a member with infinitely many later upper bounds, restrict to those bounds and repeat. Apply this to get .
The sequence is still bad. An earlier prefix word embedding into a would embed into , contrary to the original bad sequence. An embedding would extend by the comparable last letters to , equally impossible. But its next word at position is strictly shorter than , contradicting minimality. This proves Higman's lemma, including the possibility that a deleted word is empty, since that would make the proposed bad continuation impossible immediately.
We now prove the labelled version of Kruskal's tree theorem for labels in any well-quasi-order . Assume there is a bad sequence , and choose one minimal in vertex count at each position, subject to bad extendibility. Let be the collection of rooted subtrees obtained by deleting a root and taking one of its child branches, over all .
This collection is well-quasi-ordered. Otherwise take a bad sequence from . Only finitely many of these objects can come from any bounded initial segment of the , since that segment has only finitely many child branches and a bad sequence cannot repeat an object. Pass to a subsequence with a child branch of and . Then
is bad: a prefix tree embedding into would embed into , and the are already bad among themselves. The next object has fewer vertices than , contradicting the minimal bad choice. Notice that a child branch does embed into its full tree under the stated homeomorphic convention.
List each tree's child branches in any chosen order. The preceding result and Higman's lemma make these finite lists well-quasi-ordered. The product of two well-quasi-orders is well-quasi-ordered: first thin to an infinite nondecreasing subsequence in one coordinate and then find an increasing pair in the other. Therefore there are such that the root label of increases to that of , and the child list of embeds as a subsequence into the child list of , with each source branch homeomorphically embedding into its matched branch.
Map the root of to the root of , and use these branch embeddings below it. Different child branches map into different host branches, so their lowest common ancestor maps to the host root. Within each branch it is preserved by the chosen embedding. Thus the whole map is injective, preserves all lowest common ancestors and respects labels, contradicting badness. Finite rooted trees labelled by a well-quasi-order are well-quasi-ordered under homeomorphic embedding. Taking one label proves Kruskal's tree theorem. If one uses a root-preserving convention, mark the root by a separate label incomparable with all ordinary labels and apply the labelled theorem; the marked root then has to map to the marked root. No adjacency-preservation assertion is being made.
For Friedman's finite form of Kruskal's theorem, fix . The required finite conclusion is
Assume there were arbitrarily long bad sequences satisfying these size bounds. Form the tree of their finite prefixes, using rooted-tree isomorphism classes as objects. At position only finitely many finite rooted trees have at most vertices, so this prefix tree is finitely branching and has nodes at arbitrarily large depths. König infinity lemma supplies an infinite branch: at each step some child must still have arbitrarily deep extensions, because there are only finitely many children. The branch is an infinite bad sequence of finite rooted trees, contradicting Kruskal's theorem. Thus such an exists. The argument also works for any prescribed size-bound function, or any fixed finite label set, because each position then still has finitely many possible objects.
A well-quasi-ordering is a reflexive transitive relation such that every infinite sequence has with . An infinite sequence without such a pair is a bad sequence. For a finite rooted tree, let denote the lowest common ancestor of two vertices. A homeomorphic embedding of a rooted tree into another is an injective map with
Thus it preserves branching and sends each edge to a nonempty downward path, with different branches separated. The source root may map to a vertex below the target root. Kruskal's tree theorem says that finite rooted trees are well-quasi-ordered under these embeddings.
We first establish the word lemma used in the proof. The Higman lemma says that finite words over a well-quasi-ordering are well-quasi-ordered by subsequence embedding with increased letters. Every infinite sequence in has an infinite nondecreasing subsequence. To see this, some term must have infinitely many later terms above it: otherwise, repeatedly choosing past all finitely many successors of earlier chosen terms constructs a bad sequence. Apply this observation again inside that infinite upper cone, and repeat.
If the Higman lemma failed, choose a minimal bad sequence of words , minimizing length at each position among choices admitting a bad continuation. None is empty. Write , with last letter , and choose indices on which the are nondecreasing. Then
is still a bad sequence. A comparison from the original prefix into some would give one into . A comparison would extend by to . Both contradict the original badness. But the replacement at position is shorter than , contradicting minimality. This proves the Higman lemma.
Now suppose Kruskal's tree theorem fails and choose a minimal bad sequence , minimizing the number of vertices at each stage. Let contain all proper descendant-rooted subtrees of all . We claim that is well-quasi-ordered by rooted-tree homeomorphic embeddings. Otherwise take a bad sequence from it. Each finite set of host trees supplies only finitely many subtrees, so after passing to a subsequence we may arrange that is a proper subtree of with . The sequence
is bad: a comparison from a prefix tree into would compose with its inclusion into and contradict the original badness; comparisons among the are excluded by construction. Yet is smaller than , contradicting minimality. This proves the claim.
List the immediate-child subtrees of each in any fixed order. These are finite words over . By the Higman lemma, some earlier child list embeds into a later one with increased letters. The selected child subtrees embed into distinct child branches of the later tree. Map the source root to the target root and use these embeddings in the selected branches. The paths from the target root to the embedded child roots are separated because the target child branches are distinct. The resulting injection preserves lowest common ancestors, giving , a contradiction. This proves Kruskal's tree theorem completely. It also gives the root-preserving homeomorphic version: once the weaker relation is well-quasi-ordered on all finite rooted trees, apply the Higman lemma to their child lists to obtain a comparison preserving the root.
For the proposed adjacency-preserving rooted-tree embedding, the answer is no: it is not a well-quasi-ordering. For every , form from a stem of edges starting at the root and then attach two leaves to its terminal vertex. The only vertex with two children is at depth . A root-preserving adjacency injection preserves depths: the unique path of length from the root maps to a simple path of length from the target root. The image of a vertex with two children must still have two distinct children. Thus an embedding must send the branch vertex at depth to the unique branch vertex at depth , forcing . Therefore
This is the branching-depth antichain of rooted trees. Homeomorphic embeddings can stretch the stem and hence do not have this obstruction.
Figure 1.
Root-preserving adjacency embeddings preserve the depth of the branching vertex
. Details.
A well-quasi-ordering is a reflexive transitive relation for which every infinite sequence has with . A bad sequence has no such pair. The labelled version of Kruskal's tree theorem says that finite rooted trees labelled in any well-quasi-ordering are themselves well-quasi-ordered by label-monotone tree embedding.
More explicitly, an embedding is an injective map of vertices preserving lowest common ancestors, and satisfying at every vertex. The root need not map to the host root. This is a homeomorphic embedding of a rooted tree: an edge can map to a longer path, but distinct branches must separate at the image of their common ancestor. We shall prove the stronger version in which every vertex's children are linearly ordered and embeddings respect that ordering. Forgetting the child order gives the stated result for unordered rooted trees.
We first establish the two well-quasi-ordering facts used in the proof. Every infinite sequence in a well-quasi-ordering has an infinite nondecreasing subsequence. Indeed, color an index pair according to whether . The infinite two-color Ramsey theorem gives a homogeneous infinite set; the negative color would be a bad sequence, so the positive color gives the required subsequence. It follows that the componentwise product of two well-quasi-orderings is a well-quasi-ordering: first extract a nondecreasing subsequence in one coordinate, then find a good pair in the other.
Next prove Higman lemma: finite words over a well-quasi-ordering , ordered by subsequence embedding with coordinatewise increase of letters, are a well-quasi-ordering. Suppose not, and choose a minimal bad sequence by making the length of minimal among all choices admitting an infinite bad continuation of the already fixed prefix. No word is the empty word, since that embeds in every later word. Write with . Extract indices for which . Consider
It cannot be a bad sequence, since its first replacement is shorter than the minimal choice . But a good pair within the original prefix is impossible. A prefix word embedding into would embed into , contradicting the original bad sequence. And embedding into would, after appending the ordered last letters, embed into , also impossible. This contradiction proves Higman lemma, including words of arbitrary finite length.
Now suppose there is a bad sequence of finite ordered labelled rooted trees. Choose a minimal bad sequence by minimizing the number of vertices of , subject to the fixed prefix having an infinite bad continuation. Existence of a least possible size uses ordinary well-ordering of the natural numbers; after selecting such a tree retain a bad continuation to make the next choice.
Let be the collection of all proper rooted subtrees of all , with inherited labels and child ordering. These are the subtrees rooted at vertices other than the root, and each embeds into its containing tree. We claim is a well-quasi-ordering under the same label-monotone tree embedding.
Otherwise choose a bad sequence from , and choose for each a containing tree . The indices are unbounded in every tail: finitely many containing trees have only finitely many rooted subtrees, and an infinite bad sequence cannot repeatedly use one of these, since it embeds into itself. Passing to a subsequence, arrange . The spliced sequence
is bad. A good pair within either piece is already excluded. A comparison , where , would compose with to give , contradicting the original bad sequence. But is smaller than , contradicting the minimal choice at that position. This proves the claim about .
Describe by its root label and its finite ordered list of child subtrees. Every entry of lies in . By Higman lemma, is a well-quasi-ordering; hence so is . There exist with and an increasing injection matching the child subtrees in to child subtrees in , each by an embedding. Map root to root and combine these child embeddings. Different matched children lie in different target branches, so their paths meet exactly at the target root; within each branch the chosen embedding already preserves lowest common ancestors. The resulting map is a label-monotone tree embedding , a contradiction. Therefore
The empty labelled tree, if included by convention, embeds into every tree and causes no exception. A common stronger formulation requires the source root to map to the target root. It also follows: the theorem just proved makes all labelled child subtrees a well-quasi-ordering, and the product then provides a good pair with roots explicitly matched, by the same final assembly. Internal child roots may map further down their matched branches. This must not be confused with edge-to-edge embedding, for which the theorem is false in general.
Rooted tree Created 2026-09-28 Updated 2026-10-14
A rooted tree is a tree with a distinguished vertex, its root of a tree . Choosing turns connections into a hierarchy: every other vertex has a unique parent in a rooted tree, the preceding vertex on its graph path from . Conversely, the vertices whose parent in a rooted tree is are the children in a rooted tree of . Choosing the root of a tree changes this description, while the underlying edges remain the same. Arrows towards the root of a tree can encode the relationship, as in MIT's counting notes; the undirected tree itself needs no arrows. [ref]
In the seven-vertex tree above, choose . The levels, grouped by graph distance from the root of a tree, are , , , . The children in a rooted tree of are , and the parent in a rooted tree of is . Choosing instead makes the levels , , , , , : now has parent in a rooted tree , reversing their relationship. All six edges survive.
This hierarchy supports structural recursion: process the smaller rooted trees below each vertex, then combine their results. A depth-first traversal of a tree explores one branch before returning; breadth-first search processes successive levels. The lowest common ancestor identifies where two routes from the root of a tree last coincide. For it is when . A binary tree imposes an additional restriction on children in a rooted tree; a general rooted tree has no such bound.