data structures and algorithms lab8
DESCRIPTION
TRANSCRIPT
![Page 1: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/1.jpg)
DATA STRUCTURES AND ALGORITHMS
LAB 8
Bianca Tesila
FILS, April 2014
![Page 2: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/2.jpg)
OBJECTIVES
Connected Graph Hamiltonian Graph Eulerian Graph
![Page 3: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/3.jpg)
CONNECTED GRAPH
An undirected graph G = (V, A) is said to be connected if, for any vertices u and v of S, there is a chain from u to v.
![Page 4: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/4.jpg)
CONNECTED GRAPH – CONNECTED COMPONENTS
A connected component (or just component) of an undirected graph is a subgraph in which any two vertices are connected to each other by paths, and which is connected to no additional vertices in the supergraph.
![Page 5: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/5.jpg)
CONNECTED GRAPH
Classic problems: Check whether a graph is connected or not Find all the connected components of a graph
!! DFS is used to determine if a graph is connected or not.
![Page 6: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/6.jpg)
CONNECTED GRAPH
!! Exercise:Check whether a graph is connected or not.
![Page 7: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/7.jpg)
HAMILTONIAN GRAPH
Hamiltonian Path (or traceable path): a path in an undirected or directed graph that visits each vertex exactly once.
Hamiltonian Cycle (or Hamiltonian circuit): a Hamiltonian path that is a cycle. That
is, it begins and ends on the same vertex.
Hamiltonian Graph: a graph that contains a Hamiltonian cycle
!! Any Hamiltonian cycle can be converted to a Hamiltonian path by removing one of its edges.
![Page 8: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/8.jpg)
HAMILTONIAN GRAPH
https://sites.google.com/site/poggiolidiscretemath/graph-theory/hamiltonian-graphs
![Page 9: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/9.jpg)
HAMILTONIAN GRAPH
!! Exercise:Check whether a graph is Hamiltonian or not.
Hint:If G is a non-oriented with n> = 3 vertices, such that every vertex of G has the degree greater or equal to N / 2, then G is Hamiltonian graph.
![Page 10: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/10.jpg)
EULERIAN GRAPH
Eulerian Trail (or Eulerian path): a trail in a graph which visits every edge exactly once. It can end on a vertex different from the one on which it began.
Eulerian Cycle: an Eulerian trail which starts and ends on the same vertex.
Eulerian Graph: a graph that contains an Eulerian cycle
![Page 11: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/11.jpg)
EULERIAN GRAPH
A graph G, without isolated vertices, is Eulerian if and only if it is connected and the degrees of all vertices are even numbers.
Classic problem: find the Eulerian cycle in a graph.
https://sites.google.com/site/poggiolidiscretemath/graph-theory/eulerian-graphs
![Page 12: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/12.jpg)
EULERIAN GRAPH
!! Exercise:Check whether a graph is Eulerian or not.
Hint:A connected graph G is an Euler graph if and only if all vertices of G are of even degree.
![Page 13: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/13.jpg)
EULERIAN VS. HAMILTONIAN GRAPHS
!! An Eulerian circuit traverses every edge in a graph exactly once, but may repeat vertices, while a Hamiltonian circuit visits each vertex in a graph exactly once but may repeat edges.
![Page 14: Data structures and algorithms lab8](https://reader035.vdocuments.mx/reader035/viewer/2022081209/54c4b8404a7959f77e8b4618/html5/thumbnails/14.jpg)
HOMEWORK
Finish all the lab assignments.