Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all...

17
Presented by Dr. Akul Rana, Narajole Raj College

Transcript of Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all...

Page 1: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Presented by

Dr. Akul Rana, Narajole Raj College

Page 2: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Euler GraphsA closed walk in a graph G containing all the edges of G is

called an Euler line in G. A graph containing an Euler line is called an Euler graph.

We know that a walk is always connected. Since the Eulerline (which is a walk) contains all the edges of the graph, anEuler graph is connected except for any isolated vertices thegraph may contain. As isolated vertices do not contributeanything to the understanding of an Euler graph, it isassumed now onwards that Euler graphs do not have anyisolated vertices and are thus connected.

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 3: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Euler Graph

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 4: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Non-Eulerian Graph

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 5: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Theorem (Euler) A connected graph G isan Euler graph if and only if all vertices ofG are of even degree.Proof: (Necessity) Let G(V, E) be an Euler graph.Thus G contains an Euler line Z, which is a closedwalk. Let this walk start and end at the vertex u ϵV.Since each visit of Z to an intermediate vertex v of Zcontributes two to the degree of v and since Ztraverses each edge exactly once, d(v) is even for everysuch vertex. Each intermediate visit to u contributestwo to the degree of u, and also the initial and finaledges of Z contribute one each to the degree of u. Sothe degree d(u) of u is also even.

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 6: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

(Sufficiency) Let G be a connected graph andlet degree of each vertex of G be even.Assume G is not Eulerian and let G contain leastnumber of edges. Since d 2, G has a cycle. Let Zbe a closed walk in G of maximum length.Clearly, G−E(Z) is an even degree graph. Let C1

be one of the components of G−E(Z). As C1 hasless number of edges than G, it is Eulerian andhas a vertex v in common with Z. Let Z’ be anEuler line in C1. Then Z’ᴗ Z is closed in G,starting and ending at v. Since it is longer thanZ, the choice of Z is contradicted. Hence G isEulerian.

Contd...

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 7: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Theorem: A connected graph is Eulerian if and onlyif each of its edges lies on an odd number of cycles.Proof: Necessity Let G be a connected Eulerian graph and let e = uv be any edge of G. Then G−e is a u−v walk W, and so G−e =W contains an odd number of u−v paths. Thus each of the odd number of u−v paths in W together with e gives a cycle in G containing e and these are the only such cycles. Therefore there are an odd number of cycles in G containing e.Sufficiency Let G be a connected graph so that each of its edgeslies on an odd number of cycles. Let v be any vertex of G and Ev ={e1, . . . , ed} be the set of edges of G incident on v, then |Ev| = d(v)= d. For each i, 1 ≤ i≤ d, let ki be the number of cycles of Gcontaining ei. By hypothesis, each ki is odd. Let c(v) be thenumber of cycles of G containing v.Then clearly, c(v) = implying that , 2c(v) =Since 2c(v) is even and each ki is odd, d is even. Hence G isEulerian.

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 8: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Hamiltonian Graphs: A cycle passing through all the

vertices of a graph is called a Hamiltonian cycle. A graphcontaining a Hamiltonian cycle is called a Hamiltonian graph.

Hamiltonian graphs are named after Sir William Hamilton, anIrish Mathematician (1805−1865), who invented a puzzle, calledthe Icosian game, which he sold for 25 guineas to a gamemanufacturer in Dublin. The puzzle involved a dodecahedron onwhich each of the 20 vertices was labelled by the name of somecapital city in the world. The aim of the game was to construct,using the edges of the dodecahedron a closed walk of all thecities which traversed each city exactly once, beginning andending at the same city. In other words, one had essentially toform a Hamiltonian cycle in the graph corresponding to thedodecahedron.

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 9: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Dedecahedron and its graph shown with the Hamiltonian cycle

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 10: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Graph Representation in Memory

There are several possibilities to represent a graph

G = (V, E) in memory of the computer.

1. Adjacency Matrix

2. Incidence Matrix

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 11: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Adjacency Matrix

Let the set of nodes be V = {1, 2, . . . , n}with edges E ⊆ V × V , and let m := |E|.The adjacency matrix of a graph G = (V,E) is a |V | × |V | matrix A, where eachentry aij is equal to 1 if there exists anedge e = (vi , vj ) ∈ E and 0 otherwise. Incase a weighted graph is given, then aij= w(vi , vj ) .

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 12: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

The adjacency matrix of the graph depicted above is

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 13: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Incidence Matrix

The incidence matrix of a graph givesthe (0,1)-matrix which has a row for eachvertex and column for each edge,and iff vertex is incident upon edge .However, some authors define the incidencematrix to be the transpose of this, with acolumn for each vertex and a row for eachedge. The physicist Kirchhoff (1847) was thefirst to define the incidence matrix.

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 14: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian
Page 15: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

Weighted Graph

A weighted graph is a graph in whicheach branch is given anumerical weight. A weighted graph istherefore a special type of labeledgraph in which the labels are numbers(which are usually taken to bepositive).

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 16: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian

A.Rana, Narajole Raj College, Sem-IV, SEC2T, Euler Graphs

Page 17: Eulerian and Hamiltonian Graphs · 2020. 4. 19. · Hamiltonian Graphs: A cycle passing through all the vertices of a graph is called a Hamiltonian cycle. A graph containing a Hamiltonian