Euler and Hamiltonian Paths
Last Updated :
03 Feb, 2025
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.
Graph Example:
Path:
- A path is a sequence of edges where no vertex is repeated (except for starting and ending vertices in a circuit).
- Example in a graph: a path can be: 0 → 2→ 3→ 1.
Circuit:
- A circuit is a path that starts and ends at the same vertex, forming a loop.
- Example in the same graph: 0 → 2→ 3→ 1→0 is a circuit because it loops back to the starting vertex.
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.
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 G has n vertices (with n ≥ 3) and every vertex has a degree of at least n/2 , then G has a Hamiltonian cycle.
- Ore's Theorem: If a graph G 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 G 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.
Hamiltonian graph and Eulerian graph
A Hamiltonian graph contains a Hamiltonian circuit, where each vertex is visited exactly once before returning to the starting point.
And an Eulerian graph contains an Eulerian circuit, which traverses each edge exactly once before returning to the starting point.
The image below illustrates four categories of graphs, showing whether they are Hamiltonian, Eulerian, both, or neither.
Applications in Engineering
- Network Design: Hamiltonian cycles optimize routing and minimize network costs (e.g., fiber optic networks).
- Circuit Design: Euler paths reduce traces on circuit boards (e.g., efficient circuit layouts).
- DNA Sequencing: Hamiltonian paths help reconstruct DNA from overlapping fragments.
- Robotics: Euler paths plan routes to cover areas without retracing (e.g., robot vacuums).
- Logistics: Hamiltonian cycles optimize delivery routes and reduce travel costs.
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}.
Solution:
To have an Euler circuit, all vertices must have even degree.
Degrees: A(3), B(2), C(3), D(2)
Since A and C have odd degrees, this graph does not have an Euler circuit
2. Does the following graph have an Euler path? A graph with vertices {P, Q, R, S} and edges {PQ, QR, RS, SP, PR}.
Solution:
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 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}.
this graph does have a Hamiltonian path.
One such path is: A-B-C-D-E
5. Does the complete bipartite graph K3, 3 have: a) An Euler circuit, b) A Hamiltonian cycle
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)
6. Consider the Petersen graph. Does it have: a) An Euler circuit, b) A Hamiltonian cycle
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.
7. 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.
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.
8. Apply Dirac's theorem to determine if this graph has a Hamiltonian cycle: A graph with 8 vertices, each having degree at least 4.
Dirac's theorem states that if every vertex in a graph with n vertices (n ≥ 3) has degree ≥ \frac{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.
Related article: Difference Between Hamiltonian Path and Eulerian Path
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.
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.
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.
How does graph theory help in circuit design?
Euler paths are used to design circuits with minimal wire traces, reducing manufacturing complexity.
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
Hamiltonian Graph in Discrete Mathematics
Euler Graph in Discrete Mathematics
Similar Reads
Engineering Mathematics Tutorials Engineering mathematics is a vital component of the engineering discipline, offering the analytical tools and techniques necessary for solving complex problems across various fields. Whether you're designing a bridge, optimizing a manufacturing process, or developing algorithms for computer systems,
3 min read
Linear Algebra
MatricesMatrices are key concepts in mathematics, widely used in solving equations and problems in fields like physics and computer science. A matrix is simply a grid of numbers, and a determinant is a value calculated from a square matrix.Example: \begin{bmatrix} 6 & 9 \\ 5 & -4 \\ \end{bmatrix}_{2
3 min read
Row Echelon FormRow Echelon Form (REF) of a matrix simplifies solving systems of linear equations, understanding linear transformations, and working with matrix equations. A matrix is in Row Echelon form if it has the following properties:Zero Rows at the Bottom: If there are any rows that are completely filled wit
4 min read
Eigenvalues and EigenvectorsEigenvalues and eigenvectors are fundamental concepts in linear algebra, used in various applications such as matrix diagonalization, stability analysis and data analysis (e.g., PCA). They are associated with a square matrix and provide insights into its properties.Eigen value and Eigen vectorTable
10 min read
System of Linear EquationsA system of linear equations is a set of two or more linear equations involving the same variables. Each equation represents a straight line or a plane and the solution to the system is the set of values for the variables that satisfy all equations simultaneously.Here is simple example of system of
5 min read
Matrix DiagonalizationMatrix diagonalization is the process of reducing a square matrix into its diagonal form using a similarity transformation. This process is useful because diagonal matrices are easier to work with, especially when raising them to integer powers.Not all matrices are diagonalizable. A matrix is diagon
8 min read
LU DecompositionLU decomposition or factorization of a matrix is the factorization of a given square matrix into two triangular matrices, one upper triangular matrix and one lower triangular matrix, such that the product of these two matrices gives the original matrix. It is a fundamental technique in linear algebr
6 min read
Finding Inverse of a Square Matrix using Cayley Hamilton Theorem in MATLABMatrix is the set of numbers arranged in rows & columns in order to form a Rectangular array. Here, those numbers are called the entries or elements of that matrix. A Rectangular array of (m*n) numbers in the form of 'm' horizontal lines (rows) & 'n' vertical lines (called columns), is calle
4 min read
Sequence & Series
Calculus
Limits, Continuity and DifferentiabilityLimits, Continuity, and Differentiation are fundamental concepts in calculus. They are essential for analyzing and understanding function behavior and are crucial for solving real-world problems in physics, engineering, and economics.Table of ContentLimitsKey Characteristics of LimitsExample of Limi
10 min read
Cauchy's Mean Value TheoremCauchy's Mean Value theorem provides a relation between the change of two functions over a fixed interval with their derivative. It is a special case of Lagrange Mean Value Theorem. Cauchy's Mean Value theorem is also called the Extended Mean Value Theorem or the Second Mean Value Theorem.According
7 min read
Taylor SeriesA Taylor series represents a function as an infinite sum of terms, calculated from the values of its derivatives at a single point.Taylor series is a powerful mathematical tool used to approximate complex functions with an infinite sum of terms derived from the function's derivatives at a single poi
8 min read
Inverse functions and composition of functionsInverse Functions - In mathematics a function, a, is said to be an inverse of another, b, if given the output of b a returns the input value given to b. Additionally, this must hold true for every element in the domain co-domain(range) of b. In other words, assuming x and y are constants, if b(x) =
3 min read
Definite Integral | Definition, Formula & How to CalculateA definite integral is an integral that calculates a fixed value for the area under a curve between two specified limits. The resulting value represents the sum of all infinitesimal quantities within these boundaries. i.e. if we integrate any function within a fixed interval it is called a Definite
8 min read
Application of Derivative - Maxima and MinimaDerivatives have many applications, like finding rate of change, approximation, maxima/minima and tangent. In this section, we focus on their use in finding maxima and minima.Note: If f(x) is a continuous function, then for every continuous function on a closed interval has a maximum and a minimum v
6 min read
Probability & Statistics
Mean, Variance and Standard DeviationMean, Variance and Standard Deviation are fundamental concepts in statistics and engineering mathematics, essential for analyzing and interpreting data. These measures provide insights into data's central tendency, dispersion, and spread, which are crucial for making informed decisions in various en
10 min read
Conditional ProbabilityConditional probability defines the probability of an event occurring based on a given condition or prior knowledge of another event. It is the likelihood of an event occurring, given that another event has already occurred. In probability, this is denoted as A given B, expressed as P(A | B), indica
12 min read
Bayes' TheoremBayes' Theorem is a mathematical formula used to determine the conditional probability of an event based on prior knowledge and new evidence. It adjusts probabilities when new information comes in and helps make better decisions in uncertain situations.Bayes' Theorem helps us update probabilities ba
13 min read
Probability Distribution - Function, Formula, TableA probability distribution is a mathematical function or rule that describes how the probabilities of different outcomes are assigned to the possible values of a random variable. It provides a way of modeling the likelihood of each outcome in a random experiment.While a Frequency Distribution shows
13 min read
Covariance and CorrelationCovariance and correlation are the two key concepts in Statistics that help us analyze the relationship between two variables. Covariance measures how two variables change together, indicating whether they move in the same or opposite directions. Relationship between Independent and dependent variab
6 min read
Practice Questions