Difference between hamiltonian path and euler path

111,568

Solution 1

An Euler path is a path that passes through every edge exactly once. If it ends at the initial vertex then it is an Euler cycle.

A Hamiltonian path is a path that passes through every vertex exactly once (NOT every edge). If it ends at the initial vertex then it is a Hamiltonian cycle.

In an Euler path you might pass through a vertex more than once.

In a Hamiltonian path you may not pass through all edges.

Solution 2

Graph Theory Definitions

(In descending order of generality)

  • Walk: a sequence of edges where the end of one edge marks the beginning of the next edge

  • Trail: a walk which does not repeat any edges. All trails are walks.

  • Path: a walk where each vertex is traversed at most once. (paths used to refer to open walks, the definition has changed now) The property of traversing vertices at most once means that edges are also crossed at most once, hence all paths are trails.

Hamiltonian paths & Eulerian trails

  • Hamiltonian path: visits every vertex in the graph (exactly once, because it is a path)

  • Eulerian trail: visits every edge in the graph exactly once (because it is a trail, vertices may well be crossed more than once.)

Solution 3

Eulerian path must visit each edge exactly once, while Hamiltonian path must visit each vertex exactly once.

Solution 4

They are related but are neither dependent nor mutually exclusive. If a graph has an Eurler cycle, it may or may not also have a Hamiltonian cyle and vice versa.


Euler cycles visit every edge in the graph exactly once. If there are vertices in the graph with more than two edges, then by definition, the cycle will pass through those vertices more than once. As a result, vertices can be repeated but edges cannot.

Hamiltonian cycles visit every vertex in the graph exactly once (similar to the travelling salesman problem). As a result, neither edges nor vertices can be repeated.

Solution 5

I'll use a common example in biology; reconstructing a genome by making DNA samples.

De-novo assembly

To construct a genome from short reads, it's necessary to construct a graph of those reads. We do it by breaking the reads into k-mers and assemble them into a graph.

enter image description here

We can reconstruct the genome by visiting each node once as in the diagram. This is known as Hamiltonian path.

Unfortunately, constructing such path is NP-hard. It's not possible to derive an efficient algorithm for solving it. Instead, in bioinformatics we construct a Eulerian cycle where an edge represents an overlap.

enter image description here

Share:
111,568
mousey
Author by

mousey

Updated on April 12, 2020

Comments

  • mousey
    mousey about 4 years

    Can some one tell me the difference between hamiltonian path and euler path. They seem similar!

  • NG.
    NG. almost 14 years
    from: pballew.net/graphs.html Notice that for an Euler path you may visit each vertex more than once and in a Hamilton path it is not necessary to travel every edge.
  • David Thornley
    David Thornley almost 14 years
    IIRC, it's easy to find if there's a Euler path (or cycle), but whether a graph has a Hamiltonian is NP-complete.
  • Chris Diver
    Chris Diver almost 14 years
    Yes, I believe there are certain properties of a Euler path which you can use to prove a graph has a Euler path without an algorithm to traverse it. Finding a Hamiltonian path is an NP-complete, i think the algorithm involves trial and error. I thought this would be beyond the scope of the original question to add it to the answer, the OP is obviously new to graph theory :D It's been a while for me, I might dig out my old books.
  • Yaniv
    Yaniv about 11 years
    You are conflating paths and circuits. A Hamiltonian/Eulerian circuit is a path/trail of the appropriate type that also starts and ends at the same node.
  • Md. Abu Nafee Ibna Zahid
    Md. Abu Nafee Ibna Zahid about 6 years
    A path contains each vertex exactly once (exception may be the first/ last vertex in case of a closed path/cycle). So the term Euler Path or Euler Cycle seems misleading to me. It should be Euler Trail or Euler Circuit.
  • Md. Abu Nafee Ibna Zahid
    Md. Abu Nafee Ibna Zahid about 6 years
    A Path contains each vertex exactly once (exception may be the first/ last vertex in case of a closed path/cycle). So the term Euler Path or Euler Cycle seems misleading to me. It should be Euler Trail or Euler Circuit.
  • Md. Abu Nafee Ibna Zahid
    Md. Abu Nafee Ibna Zahid about 6 years
    A Path contains each vertex exactly once (exception may be the first/ last vertex in case of a closed path/cycle). So the term Euler Path or Euler Cycle seems misleading to me. It should be Euler Trail or Euler Circuit.
  • Md. Abu Nafee Ibna Zahid
    Md. Abu Nafee Ibna Zahid about 6 years
    A Path contains each vertex exactly once (exception may be the first/ last vertex in case of a closed path/cycle). So the term Euler Path or Euler Cycle seems misleading to me. It should be Euler Trail or Euler Circuit.
  • Md. Abu Nafee Ibna Zahid
    Md. Abu Nafee Ibna Zahid about 6 years
    +1 for considering the definition of Path (Each vertex traversed exactly once). The term Euler Path or Euler Cycle seems misleading to me. It should always be Euler Trail or Euler Circuit. Unfortunately other answers didn't consider the definition of Path.
  • srbcheema1
    srbcheema1 over 5 years
    I agree with Md. Abu Nafee. the name Euler path seems misleading as vertices are repeated in it. Its original name is Eulerian trail. Euler path is a misnomer.
  • Guy Coder
    Guy Coder over 4 years
    Interesting trivia. I created and added the tag euler-path and because of this answer you now top the list of Top Answers for Euler path at SO. :)
  • root-11
    root-11 about 4 years
    Please add links to the official sources of these definitions.
  • root-11
    root-11 about 4 years
    Please add links to the official sources of these definitions.