- By
**sian** - Follow User

- 144 Views
- Uploaded on

Download Presentation
## Computing Fundamentals 2 Lecture 2 A theory of Graphs

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

**Lecturer: Patrick Browne**http://www.comp.dit.ie/pbrowne/ Lecture Room K408, Labs A305 & A306 Based on Chapter 19. A Logical approach to Discrete Math By David Gries and Fred B. Schneider Computing Fundamentals 2Lecture 2A theory of Graphs**Graph theory began with Euler’s study of a particular**problem: “ the SevenBridges of K¨onigsberg. “ During the eighteenth century the city of K¨onigsberg (in East Prussia) was divided into four sections (including the island of Kneiphof) by the Pregel river. Seven bridges connected these regions and it was said that residents spent their Sunday walks trying to find a starting point so that they could walk about the city, cross each bridge exactly once, and return to their starting point.**A Theory of Graphs**• In this lecture we look at: • Graph Morphisms • Hamilton Circuits • Planar Graphs • Shortest Path**Graph Morphisms**• The two graphs below look different but are structurally the ‘same’. f.c 2(c) b f.a 1(a) 3(e) a c f.d 5(d) 4(b) d e f.b f.e • They are the ‘same’ up to the renaming of the vertices. These graphs are isomorphic.**Graph Isomorphism**• Given two graphs G and G’ with vertices V and V’. The graphs are isomorphic if there exists a 1-to-1 function f:V->V’ such that: • An isomorphism f “preserves edges” thus preserving properties of graphs that depend on edges e.g. cycles and degrees are preserved.**Isomorphism Invariant**• An isomorphic invariant for simple graphs is the existence of a simple circuit of length k ,where k is an integer > 2. Example: G1 and G2 are isomorphic since we have the invariants, similarity in degree of nodes, number of edges, length of circuits. G1 G2**Graph Isomorphism**• Sometimes we can check whether two graphs are not isomorphic. The left graph below has two vertices of degree 3 while the right one has none. • It is much harder to prove that two graphs are isomorphic. The computation is time is exponential wrt. the number of vertices.**Homeomorphic Graphs**• Two graphs are homeomorphic if they can both be obtained from the same graph by inserting or removing vertices of degree 2. 1 2 3 b e c d • Adding b to 1 gives 2 • Adding c,d,e, to 1 gives 3 • Hence 2 and 3 are homeomorphic because they were obtained from 1 by adding (removing) vertices of degree 2.**Recall: Euler and Hamiltonian Cycles**• An Euler cycle is a cycle in a graph that includes each edge exactly once. Examples: Designing and optimizing routes refuse trucks, snow ploughs, or postmen. In all of these applications, every edge in a graph must be traversed at least once. • A Hamiltonian cycle is a cycle in a graph G that contains each vertex exactly once except for the starting and ending vertex that appears twice. Examples: travelling sales man who wishes to visit every city and also minimize his route to each city and return to his home city.**Hamilton Circuit**• A Hamilton path of a graph or digraph is a path that contains each vertex exactly once, except that the end vertices may be the same. • A Hamilton circuit (or cycle) is a Hamilton path that is a cycle. • Contrast this with an Euler circuit which contains each edge exactly once.**Hamilton Path and Circuit**• G has Hamilton path but no Hamilton circuit (or cycle).**Hamiltonian cycles**• Traveling salesperson problem • To visit every vertex of a graph G only once by a simple cycle. • Such a cycle is called a Hamilton cycle. • If a connected graph G has a Hamilton cycle, G is called a Hamiltonian graph.**Hints for finding Hamilton Circuits**• If G has a HC, then deg.v >= 2 for all v on HC. • If deg.v = 2 then both edges incident on v are in HC. • If deg.v > 2 and two of the edges incident on v are in a HC, then the other edges incident on v are not in that HC. • A complete digraph (v>2) has a Hamilton Path.**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j Solution: d,a**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j Solution: d,a,e**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j Solution: d,a,e,b**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j Solution: d,a,e,b,g**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j Solution: d,a,e,b,g,c**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j Solution: d,a,e,b,g,c,h**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j Solution: d,a,e,b,g,c,h,j**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j Solution: d,a,e,b,g,c,h,j,f**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j Solution: d,a,e,b,g,c,h,j,f,i**Hamilton Circuit**• Find a Hamilton circuit in the G. b a c d e f g h i j Solution: d,a,e,b,g,c,h,j,f,i,d**Hamilton Circuit**• Find another Hamilton circuit in the same graph G. b a c d e f g h i j • Note that while verticies a and b were on previous Hamilton circuit the edge <a.b> was not.**Hamilton Circuit**• Find another Hamilton circuit in the G. b a c d e f g h i j**Hamilton Circuit**• Find another Hamilton circuit in the G. b a c d e f g h i j**Hamilton Circuit**• Find another Hamilton circuit in the G. b a c d e f g h i j**Hamilton Circuit**• Find another Hamilton circuit in the G. b a c d e f g h i j**Hamilton Circuit**• Find another Hamilton circuit in the G. b a c d e f g h i j**Hamilton Circuit**• Find another Hamilton circuit in the G. b a c d e f g h i j**Hamilton Circuit**• Find another Hamilton circuit in the G. b a c d e f g h i j**Hamilton Circuit**• Find another Hamilton circuit in the G. b a c d e f g h i j**Hamilton Circuit**• Find another Hamilton circuit in the G. b a c d e f g h i j**Is HC unique?**• There are graphs with unique Hamiltonian cycles:**Two classes of Hamiltonian Paths**• A complete digraph (v>2) has a Hamiltonian path. • Let G be an undirected graph of n Hamiltonian path vertices. If deg.b + deg.c ≥ n-1 for each pair of vertices b,cthenG has a Hamiltonian path. Note direction of implication b,c(deg.b + deg.c ≥ n-1) HP If 2 does not hold we do not know about HP**Showing there is no HC**• A HC must contain exactly two edges incident on each vertex. Hence each vertex v on the HC has degree(v)= 2. • In any graph sum(degree(v))=2*|E|. In the HC case |V|*2=2*|E|, which reduces to |V|=|E|. Since G (below) has 5 vertices then the HC should have 5 edges. v1 v2 v5 Graph G v4 v3**Showing there is no HC**Graph G v1 • Looking just at the HC in G, each vertex on the HC has degree two. We now eliminate edges incident on vertices with degree greater than two. • The edges <v4,v5> and <v2, v5> are incidentonv4, v3, v5. • If we eliminate <v4,v5> and <v2, v5> are left with only 4 edges not enough to complete a HC. v5 v4 v2 v3 v1 v5 v2 v4 v3**Showing there is no HC**• Using this method we must avoid double counting. We must not count an eliminated edges more than once. In this case, when we eliminated one edge incident on v2 and one edge incident on v4 these edges are distinct, and hence our argument is valid. v1 v5 v4 v2 v3 Graph G; valid reasoning**Incorrect claim: G has no HC.**In G2 there are 5 vertices, hence HC must have 5 edges. Following the method from previous slide we eliminate two edges incident at v5 and one edge incident at each v1,v2,v3, and v4, leaving just 2 edges, hence no HC. This is incorrect reasoning, because the red edges are counted twice. When we eliminate 2 edges incident on v5 (which we must) we also eliminate edges incident on another vertices. Then we only need to remove 1 other edge. Now we have 5 edges and 5 vertices, hence a HC –correct reasoning. G2 v1 v5 v2 v4 v3 v1 v5 v4 v2 v3**Showing there is no HC**• How could we show that there is no HC in the graph below? a c b e d f i g k j h l m**Showing there is no HC**• Suppose HC=H, then edges <a,b>, <a,g>, <b,c>,<c,k> must be in H, since each of these has at least one vertex with degree two. • Thus <b,d>and <b,f>are not in H since then Deg(b) >2 would be true. a c b e d f i g k j h l m**Showing there is no HC**• Therefore edges <g,d>, <d,e>, <e,f>, <f, k> are in H (because d and f are now degree 2). • The edges now form a cycle C. Adding additional edges to C will give some vertex in H a degree greater that 2. This is a contradiction, showing G does not have HC. a c b e d f i g k j h l m**Summary of Euler and Hamilton cycles**• A Euler cycle is a cycle in a graph that includes all of the edges and all of the vertices in that cycle. • A Hamilton cycle is a cycle in a graph G the contains each vertex exactly once except for the starting and ending vertex that appears twice. • Recall: • A path is a sequence of verticies and edges but with no edge traversed more than once • A path with at least one edge and with the first and last vertices the same is called a cycle.**Summary of Euler and Hamilton cycles**• G has a Euler cycle but no Hamilton cycle B D F C A B E

Download Presentation

Connecting to Server..