skip to main content

Dirac's theorem on Hamiltonian Graphs

Three different proofs of Dirac's theorem on Hamiltonian cycles in graphs with sufficient minimum degree.

Overview & Background

Continuing the theme of last post, we will look at a classic result in graph theory, namely Dirac’s theorem on Hamiltonian cycles. This result was first published by Gabriel A. Diracin 1952 [1], with later refinements by Ore, as well as Bondy and Chvátal. Three proofs of the theorem will be presented: the original proof from Dirac’s paper, an induction proof, and a short and direct proof. We will also consider the tightness of the bound as well as a generalization by Ore.

As a little historical sidenote before diving into the mathematics, Gabriel Dirac was the son of Margit Wigner, the sister of famous physicist Eugene Wigner. After a first marriage, from which Gabriel was born, Margit later remarried Eugene Wigner’s friend Paul Dirac, another equally famous physicist and one of the founders of Quantum Mechanics. Subsequently, Gabriel chose to take on the name Dirac. More interesting biographical details can be found in the essay about Paul Diracon MacTutor.

Table of contents

Dirac’s theorem

Although the following definitions are standard in graph theory, it is useful to specify them at the outset as these terms are often used rather loosely. A path is a sequence of non-repeating vertices and edges, where subsequent vertices are connected by an edge in the graph. Usually we distinguish between open and closed paths, where as the name implies, an open path just has different start and end vertices, while a closed path starts and ends with the same vertex. A closed path is also called a cycle. The length of a cycle is the number of distinct vertices on the cycle (the equal start- and end-vertex is not counted twice). As always, I will try to stick to common graph theoretical notation and conventions, but for the sake of both readability and completeness an overview of notation is given at the end of the post.

A Hamiltonian cycle is a cycle through a graph that visits every vertex exactly once. This concept might sound similar to Euler tours, that are historically at the origin of graph theory. An Euler tour is a cycle that visits every edge exactly once, while repeated vertices are allowed. However, in contrast to Euler tours which can be found in a graph in linear time O(V+E)\mathcal{O}(|V|+|E|), finding and even checking whether a graph contains a Hamiltonian cycle is in general NP\mathcal{NP}-complete, i.e. no known polynomial time exists for this problem. Finding a Hamiltonian cycle and the related optimization problem of finding a lowest weight Hamiltonian cycle (known as the travelling salesperson problem) has many applications from computer graphics and circuit design to cargo routing and bioinformatics.

We will consider Dirac’s theorem, which is a sufficient condition for graphs to contain a Hamiltonian cycle:

Theorem (Dirac, 1952)

Let G=(V,E)G = (V, E) be a graph with V3|V| \geq 3 and minimum degree δ(G)V2\delta(G) \geq \frac{|V|}{2} on every vertex. Then GG contains a Hamiltonian cycle.

Equivalently, every graph with minimum degree δ(G)=d\delta(G) = d and at most V2d|V| \leq 2d vertices contains a Hamiltonian cycle.

Notice that the conditions of this theorem are not necessary for a Hamiltonian cycle, as for example a cycle graph CnC_n on nn vertices violates the degree condition but clearly contains a Hamiltonian cycle.

Connectedness

As a warm-up we’ll start by showing that such a “Dirac-graph” is connected, ie. GG contains a path between any two vertices. In his original paper, Dirac writes in the theorem formulation that the graph must be connected, but as we will see now, this is not strictly necessary. Every graph that obeys the degree condition must also be connected.

In fact, we will see that any two vertices are connected by a path of length at most two, where the length of a path is defined as the number of edges along that path. Consider two arbitrary vertices u,vVu, v \in V. Without loss of generality we may assume that {u,v}∉E\{u, v\} \not \in E, as otherwise we would be done. We therefore know that the neighborhoods N(u),N(v)\mathcal{N}(u), \mathcal{N}(v) of uu and vv respectively do not contain the other vertex. But by the assumption on the minimum degree in GG we also know that N(u)V2\mathcal{N}(u) \geq \frac{|V|}{2} as well as N(v)V2\mathcal{N}(v) \geq \frac{|V|}{2}. We can now apply the pigeonhole principle to conclude that uu and vv must have a neighbor in common, and are therefore connected by a path of length 22: Both neighborhoods do not contain uu and vv by the previous observation, so we are trying to distribute two neighborhoods of size at least V2\frac{|V|}{2} onto V2|V| - 2 vertices. The two must necessarily intersect.

Alternatively, this same fact can be seen by applying the inclusion-exclusion principle:

N(u)N(v)=N(u)V2+N(v)V2N(u)N(v)V{u,v}=V22|\mathcal{N}(u) \cap \mathcal{N}(v)| = \underbrace{|\mathcal{N}(u)|}_{\geq \frac{|V|}{2}} + \underbrace{|\mathcal{N}(v)|}_{\geq \frac{|V|}{2}} - \underbrace{|\mathcal{N}(u) \cup \mathcal{N}(v)|}_{\leq |V \setminus \{u, v\}| = |V| - 2} \geq 2

We can already start seeing, why this theorem is tight. Relaxing the degree constraint on the vertices would for example allow a graph GG' that is the disjoint union of two complete subgaphs on half of the vertices: for X=KV2X = K_{\frac{|V|}{2}} and Y=KV2Y = K_{\frac{|V|}{2}} (ignoring odd V|V| for simplicity here) we could construct G=XYG' = X \uplus Y with a minimum degree of δ(G)=V21\delta(G') = \frac{|V|}{2} - 1 for every vertex. This graph clearly does not contain a Hamiltionian cycle

In the following three proofs, we will always assume that GG is a graph as described in the theorem, i.e. G=(V,E)G = (V, E) with δ(G)V2\delta(G) \geq \frac{|V|}{2}.

Original proof

Dirac’s original proof [1:1] is a little more convoluted, but we will consider it for completeness. It contains a few unnecessary convolutions, such as two nested proofs by contradiction, that hide the essence of the argument. Feel free to skip to the next section if you are not interested in the exact technical details of the original paper.

We will start by showing the following lemma:

Lemma 1

Let G=(V,E)G = (V, E) be a graph as defined in Dirac’s theorem. Then GG contains a cycle of length at least δ(G)+1\delta(G) + 1.

A longest path P=v1,,vkP = v_1, \dots, v_k in GG must contain at least V2+1\frac{|V|}{2} + 1 vertices, because v1v_1 has at least δ(G)=V2\delta(G) = \frac{|V|}{2} neighbors. Otherwise v1v_1 would have a neighbor outside of PP that we could use to extend PP. Therefore, all neighbors of v1v_1 must lie on PP, which immediately yields a cycle of length at least δ(G)+1\delta(G) + 1: v1,,vi,v1v_1, \dots, v_i, v_1 where iδ(G)+1i \geq \delta(G) + 1 is the highest index of neighbors of v1v_1 along PP.

Now assume for sake of contradiction that the theorem is false, i.e. there exists a graph G=(V,E)G = (V, E) satisfying V3|V| \geq 3 and δ(G)V2\delta(G) \geq \frac{|V|}{2} on every vertex that does not contain a Hamiltonian cycle. Let C=v1,,vkC = v_1, \dots, v_k be the longest cycle in GG. By our assumption, CC has length at most V1|V| - 1. From the lemma it also follows that the cycle CC must have length at least V2+1\frac{|V|}{2} + 1.

As GG is connected, some node in CC, let’s assume without loss of generality that it is vkv_k, must be connected to some node vk+1v_{k+1} in VCV \setminus C. We will now consider the longest path P=vk,vk+1,,vk+lP' = v_{k}, v_{k+1}, \dots, v_{k + l} that is entirely contained in VCV \setminus C except for vkv_k. By the same observation as in the proof for the lemma, vk+lv_{k + l} can only be connected to v1,,vk,,vk+l1v_1, \dots, v_k, \dots, v_{k + l - 1}.

Under these assumptions made for sake of contradiction, the following lemma holds:

Lemma 2

Under the assumption that Dirac’s theorem is false, it holds that lV2l \geq \frac{|V|}{2}.

We will show this lemma again by contradiction. If lV21<V2l \leq \frac{|V|}{2} - 1 < \frac{|V|}{2}, then vk+lv_{k+l} must be connected to at least δ(G)lV2l1\delta(G) - l \geq \frac{|V|}{2} - l \geq 1 vertices in v1,,vk1v_1, \dots, v_{k-1}, excluding vertices vk,,vk+l1v_k, \dots, v_{k+l-1} in PP'. So vk+lv_{k + l} must be connected to another vertex viCv_i \in C with vivkv_i \not = v_k. We can estable the following two inequalities on ii:

  • il+1i \geq l + 1: We can form a new cycle C=vk+l,vi,,vk,,vk+lC' = v_{k + l}, v_i, \dots, v_k, \dots, v_{k + l} of length k+li+1k + l - i + 1. Because CC is the longest cycle in GG, we obtain k+li+1k    il+1k + l - i + 1 \leq k \iff i \geq l + 1
  • ikl1i \leq k - l - 1: We could also form a new cycle C=v1,,vi,vk+l,,vk,v1C'' = v_1, \dots, v_i, v_{k + l}, \dots, v_k, v_1 of length i+l+1i + l + 1. Just as before we obtain i+l+1k    ikl1i + l + 1 \leq k \iff i \leq k - l - 1.

By the two inequalities, we conclude that vk+lv_{k + l} is connected to at least V2l1\frac{|V|}{2} - l \geq 1 vertices in I=vl+1,,vkl1I = v_{l + 1}, \dots, v_{k - l - 1}. Notice that there are I=k2l1|I| = k - 2l - 1 such vertices.

However, it is also not possible that vk+lv_{k + l} is joined to two neighboring vertices viv_i and vi+1v_{i + 1} in II, as this would contradict the maximality of the original cycle CC. Otherwise CC could have been extended to v1,,vi,vk+l,vi+1,,vk,v1v_1, \dots, v_i, v_{k + l}, v_{i + 1}, \dots, v_k, v_1 of length k+1k + 1. By this observation, there must therefore be at least 2(V2l)12 \left(\frac{|V|}{2} - l\right) - 1 such vertices in II in order to intersperse every neighboring vertex of vk+lv_{k + l} with a non-neighbor. Putting all these inequalities together, we finally obtain:

I=k2l1>2(V2l)1    kV|I| = k - 2l - 1 > 2 \left(\frac{|V|}{2} - l\right) - 1 \iff k \geq |V|

But this cannot be, as we assumed that CC is not a Hamiltonian cycle. This proves lemma 2.

Proving Dirac’s theorem is now fairly straightforward, by completing the outer proof by contradiction. As we have already observed previously, CC has length at least V2+1\frac{|V|}{2} + 1 by lemma 1. Because GG is composed of at least CC and PP', both distinct from each other by construction, we can apply our bound on P|P'| from lemma 2:

VC+PV2+1+V2V+1|V| \geq |C| + |P'| \geq \frac{|V|}{2} + 1 + \frac{|V|}{2} \geq |V| + 1

This contradiction concludes the proof.

Double induction

As a first proof of Dirac’s theorem, we will consider a proof by induction. This uses the so-called rotation-extension technique by Pósa[2]. Personally, I find this proof to be the most elegant of the three, especially because of the neat double induction that is used. The general structure of the proof consists of two parts:

  • A kk-cycle implies the existence of a k+1k+1-path, as GG is connected
  • A kk-path implies the existence of a k+1k+1-path or a kk cycle.

By induction GG thus has an V|V|-cycle, i.e. a Hamiltonian cycle.

Recall that we already saw previously, that G is connected. This fact will be needed in the induction proof.

Induction I

Induction proof I

For k<Vk < |V|, a kk-cycle implies the existence of a k+1k+1-path.

Let C=v1,,vk,v1C = v_1, \dots, v_k, v_1 be such a cycle in GG. Because GG is connected, there exists an edge e=(w,vi)e = (w, v_i) from V{v1,,vk}V \setminus \{v_1, \dots, v_k\} to CC, where ww is a vertex outside of the cycle. Without loss of generality we may assume that vi=v1v_i = v_1. We have found a k+1k+1-path wv1vkw \rightarrow v_1 \rightarrow \dots \rightarrow v_k.

Induction II

A kk-path implies the existence of a k+1k+1-path or a kk-cycle.

Let P=v1,,vkP = v_1, \dots, v_k be such a path in GG.

  1. Case N(v1)⊈{v2,,vk}\mathcal{N}(v_1) \not \subseteq \{v_2, \dots, v_k\}: PP can be extended to a k+1k+1-path wv1vkw \rightarrow v_1 \rightarrow \dots \rightarrow v_k, where ww is a neighbor of v1v_1 not in PP.

  2. Case N(vk)⊈{v1,,vk1}\mathcal{N}(v_k) \not \subseteq \{v_1, \dots, v_{k-1}\}: same as above

  3. Induction proof II Case N(v1){v2,,vk}\mathcal{N}(v_1) \subseteq \{v_2, \dots, v_k\} and N(vk){v1,,vk1}\mathcal{N}(v_k) \subseteq \{v_1, \dots, v_{k-1}\}:

    Let the extended neighborhood N+(vk):={vi+1    viN(vk)}\mathcal{N}^+(v_k) := \{ v_{i+1} \;\vert\; v_i \in \mathcal{N}(v_k)\} be the set of successors of neighbors on the path. Note that by assumption, all neighbors (and their successors) of vkv_k lie on PP. By applying the inclusion-exclusion principle again we obtain:

    N(v1)N+(vk)=N(v1)V/2+N+(vk)V/2N(v1)N+(vk)V{v1}    V11|\mathcal{N}(v_1) \cap \mathcal{N}^+(v_k)| = \underbrace{|\mathcal{N}(v_1)|}_{\geq |V|/2} + \underbrace{|\mathcal{N}^+(v_k)|}_{\geq |V|/2} - \underbrace{|\mathcal{N}(v_1) \cup \mathcal{N}^+(v_k)|}_ {\subseteq V\setminus\{v_1\} \implies \leq |V| - 1} \geq 1

    This implies that there exists a viv_i in N(v1)N+(vk)\mathcal{N}(v_1) \cap \mathcal{N}^+(v_k). We have found a kk-cycle v1vivkvi+1v1v_1 \rightarrow \dots \rightarrow v_i \rightarrow v_k \rightarrow \dots \rightarrow v_{i+1} \rightarrow v_{1}

Conclusion

By combining both parts of the induction, we conclude that there must exist an nn-path, and by Induction II, an V|V|-cycle, i.e. a Hamiltonian cycle in GG, as GG cannot contain an V+1|V|+1 path (paths have distinct vertices).

Direct proof

This is the shortest of the three proofs that will be presented, and is conceptually very similar to the induction proof. It can be found in standard textbooks on graph theory, such as the one by Diestel [3]. We will first inspect a longest path in GG and show that it can be extended to a cycle. We will then prove that this cycle must actually be a Hamiltonian cycle.

Consider a longest path P=v1,,vkP = v_1, \dots, v_k in GG. All edges of v1v_1 and vkv_k must end in PP, as otherwise we could extend PP, contradicting the fact that PP is a longest path. By the same argument as in case 3 of Induction II, we can find an edge vivi+1v_i v_{i+1} in the path, where also both {v1,vi+1}E\{v_1, v_{i+1}\} \in E and {vi,vk}E\{v_i, v_k\} \in E. We can then turn PP into a cycle C=v1,vi+1,,vk,vi,,v1C = v_1, v_{i+1}, \dots, v_k, v_i, \dots, v_1.

Finally, assume for sake of contradiction that CC is not a Hamiltonian cycle. Then there must exist at least one vertex in VCV \setminus C. However, as GG is connected, there must also exist an edge {u,vi}\{u, v_i\} for uVCu \in V \setminus C and viCv_i \in C, where we can assume vi=v1v_i = v_1 without loss of generality. This is a contradiction to our initial assumption that PP is a longest path in GG, as u,v1,,vku, v_1, \dots, v_k would form a longer path.

Tightness

We will use the second equivalent formulation of Dirac’s theorem, that bounds the number of vertices as a function of the minimum degree d=δ(G)d = \delta(G). This will make the tightness result simpler to formulate.

Let us first make a general observation about bipartite graphs that will come in handy in a moment. Recall that bipartite graphs are graphs that can be seperated into a disjoint union of two sets XX and YY with edges only between these two sets.

Lemma

Bipartite graphs cannot contain cycles of odd length (where length refers to the number of edges along the path).
Equivalently, a cycle v1,,vn,v1v_1, \dots, v_n, v_1 with nn odd cannot exist.

First, notice that any path in a bipartite graph consists of alternating vertices from both sets, because a vertex is only connected to vertices from the other set. Therefore any path of odd length must have start and end vertices in different sets, which cannot possibly form a cycle where start and end vertex are the same.

The construction exhibiting tightness is a simple bipartite construction. We will construct a graph with 2d+12d+1 vertices and show that this graph does not contain a Hamiltonian cycle. Consider vertices v1,,v2d+1v_1, \dots, v_{2d+1} and let “even” vertices be those with an even index while “odd” vertices refer to those with an odd index. We connect every even vertex only to all other odd vertices and vice-versa. This construction can also be compactly written as Kd+1,dK_{d+1, d} using standard graph theory notation.

There are d+1d+1 odd vertices and dd even vertices, i.e. we are “barely” violating the degree conditions of the initial theorem. Even vertices have degree deven=2d+12=d+1d_{\text{even}} = \lceil \frac{2d+1}{2} \rceil = d + 1 while odd vertices have degree dodd=2d+12=dd_{\text{odd}} = \lfloor \frac{2d+1}{2} \rfloor = d.

Notice however, that this graph is clearly bipartite: Color say all even vertices red and all odd vertices blue, then by construction vertices of the same parity are not connected. But bipartite graphs cannot contain odd-length cycles as seen in the lemma above, which shows that this construction cannot contain a Hamiltonian cycle.

Ore’s theorem

Finally, let’s consider a generalization of Dirac’s theorem. The Norwegian mathematician Øystein Orepublished the following theorem in a one-page paper in 1960[4]:

Theorem (Ore, 1952)

Let G=(V,E)G = (V, E) be a graph with V3|V| \geq 3. If for every pair of non-adjacent vertices uu and vv with {u,v}∉E\{u, v\} \not \in E we have degG(u)+degG(v)V\deg_G(u) + \deg_G(v) \geq |V|, then GG contains a Hamiltonian cycle.

This observation essentially follows from the proofs presented above. In the previous proofs, we repeatedly made use of the fact that two disconnected vertices can be connected through two adjacent neighbors. The condition that degG(u)+degG(v)V\deg_G(u) + \deg_G(v) \geq |V| for two non-adjacent vertices ensures exactly this: The neighborhoods N(u)\mathcal{N}(u) and N(v)\mathcal{N}(v) must intersect.

We will prove this by contrapositive:

Assume for sake of contradiction that Ore’s theorem is false, i.e. there exists a graph with V3|V| \geq 3 satisfying degG(u)+degG(v)V\deg_G(u) + \deg_G(v) \geq |V| for {x,y}∉E\{ x, y \} \not \in E that does not contain a Hamiltonian cycle. Let GG be the the one with a maximum number of edges among those. Notice that GG must contain a non-edge {x,y}∉E\{x, y\} \not \in E, as the complete graph KVK_{|V|} clearly contains a Hamiltonian cycle. Therefore we know the statement does not just hold vacuously.

Now, adding {x,y}\{x, y\} to GG must necessarily close a Hamiltonian cycle x=v1,,vn=yx = v_1, \dots, v_n = y by our choice of GG. Here we can however again apply case 3 of the induction proof (with the knowledge that N(x)+N+(y)V|\mathcal{N}(x)| + |\mathcal{N}^+(y)| \geq |V|) to conclude that {x,y}\{x, y\} was not necessary to close the Hamiltonian cycle. There must be an edge vivi+1v_i v_{i+1} in the path, where also both {x,vi+1}EG\{x, v_{i+1}\} \in E_G and {vi,y}EG\{v_i, y\} \in E_G. We obtain a cycle C=x,vi+1,,y,vi,,xC = x, v_{i+1}, \dots, y, v_i, \dots, x in GG, a contradiction.

Further reading

Overview of notation

  • Complete graph KnK_n on nn vertices
  • Neighborhood N(v)\mathcal{N}(v): set of vertices adjacent to vv
  • Extended neighborhood N+(u)\mathcal{N}^+(u) over an order of vertices: sucessors of neighbors of uu
    N+(u):={vi+1    viN(u)}\mathcal{N}^+(u) := \{ v_{i+1} \;\vert\; v_i \in \mathcal{N}(u)\}
  • Minimum degree δ(G):=minvVdegG(v)\delta(G) := \min_{v \in V} \deg_G(v)

References

  1. Dirac, G.A. (1952), Some Theorems on Abstract Graphs. Proceedings of the London Mathematical Society, s3-2: 69-81. https://doi.org/10.1112/plms/s3-2.1.69↩︎ ↩︎

  2. Pósa, L. (1976). Hamiltonian circuits in random graphs. Discrete Mathematics, 14, 359-364. https://doi.org/10.1016/0012-365X(76)90068-6↩︎

  3. Diestel, R. (2017). Graph theory. Graduate texts in mathematics. https://doi.org/10.1007/978-3-662-53622-3↩︎

  4. Ore, O. (1960). Note on Hamilton Circuits. The American Mathematical Monthly, 67(1), 55–55. https://doi.org/10.2307/2308928↩︎