Mathematics | Euler and Hamiltonian Paths

Last Updated : 01 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Euler and Hamiltonian paths are fundamental concepts in graph theory, a branch of mathematics that studies the properties and applications of graphs. An Euler path visits every edge of a graph exactly once, while a Hamiltonian path visits every vertex exactly once. These paths have significant applications in various fields, including computer science, engineering, and operations research.

Euler-and-Hamiltonian-Paths-copy

Euler Paths and Circuits

  • An Euler path is a path that uses every edge of a graph exactly once.
  • An Euler circuit is a circuit that uses every edge of a graph exactly once.
  • An Euler path starts and ends at different vertices.
  • An Euler circuit starts and ends at the same vertex.

The Konigsberg bridge problem’s graphical representation : 

Conditions for Euler Paths and Circuits

  • Euler Path: A connected graph has an Euler path if and only if it has exactly zero or two vertices of odd degree.
  • Euler Circuit: A connected graph has an Euler circuit if and only if every vertex has an even degree.

Hamiltonian Paths

  • Hamiltonian Path: A path in a graph that visits every vertex exactly once.

Unlike Euler paths, there is no simple necessary sufficient condition for the existence of Hamiltonian paths and cycles. However, there are several theorems and heuristics:

  • Dirac’s Theorem: If a graph GGG has n vertices (with n≥3n \geq 3n≥3) and every vertex has a degree of at least n/2n/2n/2, then G has a Hamiltonian cycle.
  • Ore’s Theorem: If a graph GGG has n vertices and for every pair of non-adjacent vertices u and v, the sum of their degrees is at least n, then G has a Hamiltonian cycle.

Hamiltonian Circuit

A simple circuit in a graph [Tex]G   [/Tex]that passes through every vertex exactly once is called a Hamiltonian circuit. Unlike Euler paths and circuits, there are no simple necessary and sufficient criteria to determine if there are any Hamiltonian paths or circuits in a graph. But there are certain criteria that rule out the existence of a Hamiltonian circuit in a graph, such as if there is a vertex of degree one in a graph then it is impossible for it to have a Hamiltonian circuit. 
There are certain theorems which give sufficient but not necessary conditions for the existence of Hamiltonian graphs. 

Euler and Hamiltonian Paths – Solved Examples

1. Determine if the following graph has an Euler circuit:

A graph with vertices {A, B, C, D} and edges {AB, BC, CD, DA, AC}

A: To have an Euler circuit, all vertices must have even degree.

Degrees: A(3), B(2), C(3), D(2)

Since all vertices have even degree, this graph has an Euler circuit.

One possible circuit: A-B-C-D-A-C-A

2. Does the following graph have an Euler path?

A graph with vertices {P, Q, R, S} and edges {PQ, QR, RS, SP, PR}

A: For an Euler path, either all vertices have even degree, or exactly two vertices have odd degree.

Degrees: P(3), Q(2), R(3), S(2)

This graph has an Euler path (but not a circuit) because it has exactly two odd-degree vertices.

One possible path: P-S-R-Q-P-R

3. Determine if the following graph has a Hamiltonian cycle:

A complete graph K5 with 5 vertices

A: A complete graph Kn always has a Hamiltonian cycle for n ≥ 3.

So yes, K5 has a Hamiltonian cycle.

One possible cycle: 1-2-3-4-5-1

4. Does the following graph have a Hamiltonian path?

A graph with vertices {A, B, C, D, E} and edges {AB, BC, CD, DE, AE, AC}

A: This graph does have a Hamiltonian path.

One such path is: A-B-C-D-E

5. Given a graph G with 5 vertices, each of degree 4, determine if it has:

a) An Euler circuit

b) A Hamiltonian cycle

A: a) Yes, it has an Euler circuit because all vertices have even degree.

b) Yes, it has a Hamiltonian cycle. This is a complete graph K5, which always has a Hamiltonian cycle.

6. Does the complete bipartite graph K3,3 have:

a) An Euler circuit

b) A Hamiltonian cycle

A: a) No Euler circuit. All vertices have odd degree (3).

b) Yes, it has a Hamiltonian cycle. One possible cycle: 1-a-2-b-3-c-1 (where 1,2,3 are in one partition and a,b,c are in the other)

7. Consider the Petersen graph. Does it have:

a) An Euler circuit

b) A Hamiltonian cycle

A: a) No Euler circuit. All vertices have degree 3 (odd).

b) No Hamiltonian cycle. The Petersen graph is a well-known example of a 3-regular graph without a Hamiltonian cycle.

8. How many edges need to be added to make an Euler circuit in a graph with 6 vertices, where 4 vertices have degree 3 and 2 vertices have degree 2?

A: To create an Euler circuit, all vertices must have even degree.

We need to add 1 edge to each of the 4 vertices with degree 3.

Total edges to add: 4/2 = 2 edges

9. Use Ore’s theorem to determine if this graph has a Hamiltonian cycle:

A graph with 5 vertices where the degree sum of any two non-adjacent vertices is at least 5.

A: Ore’s theorem states that if the sum of degrees of any two non-adjacent vertices is ≥ n (where n is the number of vertices), then the graph has a Hamiltonian cycle.

Here, n = 5, and the condition is satisfied.

Therefore, this graph has a Hamiltonian cycle.

10. Apply Dirac’s theorem to determine if this graph has a Hamiltonian cycle:

A graph with 8 vertices, each having degree at least 4.

A: Dirac’s theorem states that if every vertex in a graph with n vertices (n ≥ 3) has degree ≥ n/2, then the graph has a Hamiltonian cycle.

Here, n = 8, and n/2 = 4.

Since each vertex has degree at least 4, Dirac’s theorem applies.

Therefore, this graph has a Hamiltonian cycle.

Practice Questions – Euler and Hamiltonian Paths

1. Determine if the following graph has an Euler circuit:

A graph with vertices {A, B, C, D, E} and edges {AB, BC, CD, DE, EA, AC, BD}

2. Does the complete graph K6 have a Hamiltonian cycle? If so, how many distinct Hamiltonian cycles does it have?

3. For a graph G with 7 vertices, each of degree 4, determine if it has:

a) An Euler path

b) A Hamiltonian path

4. Consider the Petersen graph. How many edges need to be added to create an Euler circuit?

5. Apply Ore’s theorem to determine if this graph has a Hamiltonian cycle:

A graph with 6 vertices where the degree sum of any two non-adjacent vertices is at least 6.

6. Does the complete bipartite graph K4,3 have:

a) An Euler path

b) A Hamiltonian cycle

7. In a graph with 8 vertices, what’s the minimum number of edges required to guarantee the existence of a Hamiltonian cycle according to Dirac’s theorem?

8. A graph G has 10 vertices. Five vertices have degree 4, three vertices have degree 3, and two vertices have degree 5. Does G have an Euler circuit? If not, can it have an Euler path?

9. Prove or disprove: If a graph has a Hamiltonian cycle, it must also have an Euler circuit.

10. Consider a graph G with 5 vertices and 7 edges. Is it possible for G to have both an Euler circuit and a Hamiltonian cycle? Justify your answer.

Applications in Engineering

1. Network Design

Hamiltonian paths and cycles are used in network design to ensure efficient routing and minimize the cost of network construction.

Example: Designing a fiber optic network that connects multiple cities with minimal cable length can be modeled as a Hamiltonian cycle problem.

2. Circuit Design

In electronic circuit design, Euler paths are used to design circuits that minimize the number of traces needed on a circuit board.

Example: Creating a circuit layout where each wire trace is used exactly once can be solved using an Euler path algorithm.

3. DNA Sequencing

Hamiltonian paths are used in bioinformatics for DNA sequencing, where the goal is to reconstruct the original sequence from overlapping fragments.

Example: Reconstructing a DNA sequence from short reads involves finding a Hamiltonian path through the overlap graph of the reads.

4. Robotics

Euler paths are used in robotics for route planning and covering every area of a space without retracing steps.

Example: Programming a robot vacuum to cover every part of a floor exactly once uses an Euler path algorithm.

5. Logistics and Routing

Hamiltonian paths and cycles are used in logistics to optimize delivery routes and minimize travel costs.

Example: Determining the most efficient route for a delivery truck to visit each customer exactly once and return to the depot can be solved using Hamiltonian cycle algorithms.

Conclusion – Euler and Hamiltonian Paths

Euler and Hamiltonian paths are essential concepts in graph theory with wide-ranging applications in network design, circuit design, DNA sequencing, robotics, and logistics. Understanding the conditions for the existence of these paths and cycles and applying appropriate algorithms can solve complex problems involving discrete structures and optimization.

FAQs on Euler and Hamiltonian Paths

What is the difference between an Euler path and a Hamiltonian path?

An Euler path visits every edge of a graph exactly once, while a Hamiltonian path visits every vertex of a graph exactly once.

What are the conditions for a graph to have an Euler circuit?

A graph has an Euler circuit if and only if it is connected and every vertex has an even degree.

Is there a simple condition for the existence of Hamiltonian cycles?

There is no simple necessary and sufficient condition for Hamiltonian cycles, but theorems like Dirac’s and Ore’s provide useful criteria.

How are Hamiltonian paths used in DNA sequencing?

Hamiltonian paths are used to reconstruct the original DNA sequence from overlapping fragments by finding a path through the overlap graph of the reads.

Can Euler paths be used in robotics?

Yes, Euler paths are used in robotics for route planning to cover every area of a space without retracing steps.

GATE CS Corner Questions

Practicing the following questions will help you test your knowledge. All questions have been asked in GATE in previous years or in GATE Mock Tests. It is highly recommended that you practice them. 

1. GATE CS 2007, Question 23 
2. GATE CS 2005, Question 84 
3. GATE CS 2008, Question 26 



Previous Article
Next Article

Similar Reads

Count all Hamiltonian paths in a given directed graph
Given a directed graph of N vertices valued from 0 to N - 1 and array graph[] of size K represents the Adjacency List of the given graph, the task is to count all Hamiltonian Paths in it which start at the 0th vertex and end at the (N - 1)th vertex. Note: Hamiltonian path is defined as the path which visits every vertex of the graph exactly once. E
9 min read
Print all Hamiltonian Cycles in an Undirected Graph
Given an undirected Graph consisting of N nodes in the form of an adjacency matrix graph[][] of size N*N, the task is to print all Hamiltonian cycles possible in the given undirected Graph (taking starting vertex as '0'). A Hamiltonian cycle (or Hamiltonian circuit) is a Hamiltonian Path such that there is an edge (in the graph) from the last verte
15 min read
Euler Graph and Arbitrarily Traceable Graphs in Graph Theory
Prerequisites: Walks, trails, paths, cycles, and circuits in a graph If some closed walk in a graph contains all the vertices and edges of the graph, then the walk is called an Euler Line or Eulerian Trail and the graph is an Euler Graph. In this article, we will study the Euler graph and arbitrarily traceable graph. Consider an Euler Graph shown i
2 min read
Euler Circuit in a Directed Graph
Eulerian Path is a path in graph that visits every edge exactly once. Eulerian Circuit is an Eulerian Path which starts and ends on the same vertex. A graph is said to be eulerian if it has a eulerian cycle. We have discussed eulerian circuit for an undirected graph. In this post, the same is discussed for a directed graph. For example, the followi
13 min read
Walks, Trails, Paths, Cycles and Circuits in Graph
Walk, trails, paths, cycles, and circuits in the graph are the alternate sequences of vertices and edges with different properties that in some sequences vertex and edge repetition is allowed, and in others, it is not allowed. In this article, we will explore walks, trails, paths, cycles, and circuits in graphs along with examples. Table of Content
5 min read
Mathematics | Unimodal functions and Bimodal functions
Unimodal Function : A function f(x) is said to be unimodal function if for some value m it is monotonically increasing for x≤m and monotonically decreasing for x≥m. For function f(x), maximum value is f(m) and there is no other local maximum. See figure (A) and (B): In figure (A), graph has only one maximum point and rest of the graph goes do
2 min read
Mathematics | Rings, Integral domains and Fields
Prerequisite - Mathematics | Algebraic Structure Ring - Let addition (+) and Multiplication (.) be two binary operations defined on a non empty set R. Then R is said to form a ring w.r.t addition (+) and multiplication (.) if the following conditions are satisfied: (R, +) is an abelian group ( i.e commutative group) (R, .) is a semigroup For any th
7 min read
Application of Derivative - Maxima and Minima | Mathematics
The Concept of derivative can be used to find the maximum and minimum value of the given function. We know that information about and gradient or slope can be derived from the derivative of a function. We try to find a point which has zero gradients then locate maximum and minimum value near it. It is of use because it can be used to maximize profi
3 min read
Subgroup and Order of Group | Mathematics
In mathematics, a group is a fundamental algebraic structure consisting of a set of elements combined with a binary operation that satisfies four key properties: closure, associativity, identity, and invertibility. An example of a group is the set of integers under addition. In this case, the binary operation is addition (+), the identity element i
7 min read
Cayley Table and Cyclic Group | Mathematics
Cyclic groups are a foundational concept in group theory, a branch of abstract algebra that studies algebraic structures known as groups. A cyclic group is a group that can be generated by a single element, meaning every element in the group can be expressed as a power (or multiple) of this generator. This generator is often referred to as the "pri
6 min read
Graph Isomorphisms and Connectivity | Engineering Mathematics
Graph theory is a fundamental area in mathematics and computer science, which studies the properties of graphs and their applications. Two essential concepts in graph theory are graph isomorphisms and connectivity. Graph isomorphisms help determine if two graphs are structurally identical, while connectivity measures the degree to which the vertice
3 min read
Partial Orders and Lattices (Set-2) | Mathematics
Partial orders and lattices are important concepts in discrete mathematics and are widely used in computer science, especially in data structures, database theory, and the theory of computation. Partial orders and lattices play pivotal roles in a wide array of applications within engineering, computer science, and beyond. These structures enable th
9 min read
PDNF and PCNF in Discrete Mathematics
PDNF (Principal Disjunctive Normal Form)It stands for Principal Disjunctive Normal Form. It refers to the Sum of Products, i.e., SOP. For eg. : If P, Q, and R are the variables then (P. Q'. R) + (P' . Q . R) + (P . Q . R') is an example of an expression in PDNF. Here '+' i.e. sum is the main operator. You might be confused about whether there exist
4 min read
Mathematics | Sequence, Series and Summations
Sequences, series, and summations are fundamental concepts of mathematical analysis and it has practical applications in science, engineering, and finance. Table of Content What is Sequence?Theorems on SequencesProperties of SequencesWhat is Series?Properties of SeriesTheorems on SeriesSummation DefinitionProperties of Summation FormulaExamples of
8 min read
Mathematics | Independent Sets, Covering and Matching
Mathematics | Independent Sets, Covering and Matching1. Independent SetsA set of vertices I is called an independent set if no two vertices in set I are adjacent to each other in other words the set of non-adjacent vertices is called an independent set.It is also called a stable set.The parameter α0(G) = max { |I|: I is an independent set in G } is
5 min read
Mathematics | Power Set and its Properties
For a given set S, Power set P(S) or 2^S represents the set containing all possible subsets of S as its elements. For example, S = {1, 2, 3} P(S) = {ɸ, {1}, {2}, {3} {1,2}, {1,3}, {2,3}, {1,2,3}} Number of Elements in Power SetFor a given set S with n elements, number of elements in P(S) is 2^n. As each element has two possibilities (present or abs
6 min read
Mathematics | PnC and Binomial Coefficients
Permutations and Combinations (PnC) are fundamental concepts in combinatorics and are essential for counting and arranging objects. Binomial coefficients are closely related and used in various mathematical formulas, including the Binomial Theorem. These concepts are widely used in engineering, computer science, probability, and statistics for solv
5 min read
Surd and Indices in Mathematics
Indices and surds are very important ideas in math, specifically within algebra. They are useful when it comes to reducing expressions and resolving equations with different roots or powers involved. To be able to deal with various mathematical problems that range from simple algebraic ones to complex cases, it is vital to yet understand these conc
6 min read
Four Color Theorem and Kuratowski’s Theorem in Discrete Mathematics
The Four Color Theorem and Kuratowski's Theorem are two fundamental results in discrete mathematics, specifically in the field of graph theory. Both theorems address the properties of planar graphs but from different perspectives. In this article, we will understand about Four Color Theorem and Kuratowski’s Theorem in Discrete Mathematics, their de
14 min read
Differences between Data paths
Prerequisite - ALU and Data Path In this section, we shall discuss the difference between data-paths. These data-paths are: Single CycleMultiple CyclePipeline In single cycle clock cycle time is long enough for instruction while in multi cycle and pipeline clock cycle time is short enough for the instructions. Now, the difference among them are giv
2 min read
Mathematics | Probability Distributions Set 2 (Exponential Distribution)
The previous article covered the basics of Probability Distributions and talked about the Uniform Probability Distribution. This article covers the Exponential Probability Distribution which is also a Continuous distribution just like Uniform Distribution. Introduction - Suppose we are posed with the question- How much time do we need to wait befor
5 min read
Discrete Mathematics | Types of Recurrence Relations - Set 2
Prerequisite - Solving Recurrences, Different types of recurrence relations and their solutions, Practice Set for Recurrence Relations The sequence which is defined by indicating a relation connecting its general term an with an-1, an-2, etc is called a recurrence relation for the sequence. Types of recurrence relations First order Recurrence relat
4 min read
Mathematics | Indefinite Integrals
Antiderivative - Definition :A function ∅(x) is called the antiderivative (or an integral) of a function f(x) of ∅(x)' = f(x). Example : x4/4 is an antiderivative of x3 because (x4/4)' = x3. In general, if ∅(x) is antiderivative of a function f(x) and C is a constant.Then, {∅(x)+C}' = ∅(x) = f(x). Indefinite Integrals
4 min read
Mathematics | Generating Functions - Set 2
Prerequisite - Generating Functions-Introduction and Prerequisites In Set 1 we came to know basics about Generating Functions. Now we will discuss more details on Generating Functions and its applications. Exponential Generating Functions - Let [Tex]h_0, h_1, h_2, ........., h_n, ...... [/Tex]e a sequence. Then its exponential generating function,
3 min read
Mathematics | Renewal processes in probability
A Renewal process is a general case of Poisson Process in which the inter-arrival time of the process or the time between failures does not necessarily follow the exponential distribution. A counting process N(t) that represents the total number of occurrences of an event in the time interval (0, t] is called a renewal process, if the time between
2 min read
Definite Integral | Mathematics
Definite integrals are the extension after indefinite integrals, definite integrals have limits [a, b]. It gives the area of a curve bounded between given limits. [Tex]\int_{a}^{b}F(x)dx [/Tex], It denotes the area of curve F(x) bounded between a and b, where a is the lower limit and b is the upper limit. Note: If f is a continuous function defined
1 min read
Mathematics | Problems On Permutations | Set 2
Prerequisite - Permutation and Combination, Permutations | Set 1 Formula's Used : P(n, r) = n! / (n-r)! Example-1 : How many words can be formed from the letters of the word WONDER, such that these begin with W and end with R? Explanation : If we fix W in the beginning and R at the end, then the remaining 4 letters can be arranged in 4P4 ways. Thus
3 min read
Gamma Distribution Model in Mathematics
Introduction : Suppose an event can occur several times within a given unit of time. When the total number of occurrences of the event is unknown, we can think of it as a random variable. Now, if this random variable X has gamma distribution, then its probability density function is given as follows. [Tex]f(x) = \frac{1}{\beta^\alpha Γ(\alpha)} x^{
2 min read
Elementary Matrices | Discrete Mathematics
Prerequisite : Knowledge of Matrices & Identity Matrix Introduction :A matrix is a collection of numbers arranged in a row-by-row and column-by-column arrangement. The elements of a matrix must be enclosed in parenthesis or brackets.Example - The 3 * 3 matrix means a matrix with 3 rows & 3 columns with a total of 9 elements. (3*3 = 9) Ident
3 min read
Discrete Mathematics - GATE CSE Previous Year Questions
Solving GATE Previous Year's Questions (PYQs) not only clears the concepts but also helps to gain flexibility, speed, accuracy, and understanding of the level of questions generally asked in the GATE exam, and that eventually helps you to gain good marks in the examination. Previous Year Questions help a candidate practice and revise for GATE, whic
4 min read