Download
chapter 8 topics in graph theory n.
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter 8. Topics in Graph Theory PowerPoint Presentation
Download Presentation
Chapter 8. Topics in Graph Theory

Chapter 8. Topics in Graph Theory

259 Views Download Presentation
Download Presentation

Chapter 8. Topics in Graph Theory

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Chapter 8. Topics in Graph Theory Weiqi Luo (骆伟祺) School of Software Sun Yat-Sen University Email:weiqi.luo@yahoo.com Office:A309

  2. Chapter eight: Topics in Graph Theory • 8.1. Graphs • 8.2. Euler Paths and Circuits • 8.3. Hamiltonian Paths and Circuits • 8.4. Transport Networks • 8.5. Matching Problems • 8.6. Coloring Graphs

  3. 8.1 Graphs • Graph A graph G=(V, E, γ) consists of a finite set V of objects called vertices, a finite set E of objects called edges, and a function γ that assigns to each edge a subset {v, w}, where v and w are vertices (and may be the same). • End points If γ(e)={v, w}, then vertices v and w are called the end points of e.

  4. 8.1 Graphs • Example 1 & 2 Let V={1,2,3,4} and E={e1,e2,e3,e4,e5}. Let γ be defined by γ(e1)= γ(e5)={1,2}, γ(e2)={4,3}, γ(e3)={1,3}, γ(e4)={2,4} . Then G=(V,E,γ) is a graph. Isomorphic Graphs 1 2 1 2 1 2 3 4 4 3 3 4 G G G

  5. 8.1 Graphs • Degree The degree of a vertex is the number of edges having that vertex as an end point. • Loop An edge is referred to as a loop if the edge is from a vertex to itself. Note: a loop contributes 2 to the degree of a vertex, since that vertex serves as both end points of the loop. • Isolated A vertex with degree 0 is called an isolated vertex.

  6. 8.1 Graphs • Example 3 p a b A B q s 2 5 r C E 3 c 4 t u d D 1 6 e A: 2 B:4 C: 1 D: 3 E: 2 a: 4 b:2 c: 3 d: 1 e: 0 All edges with degree 2

  7. 8.1 Graphs • Path in a Graph A path п in a graph G consists of a pair (Vп, Eп) of sequences: a vertex sequence Vп : v1, v2, …, vk and an edge sequence E п :e1, e2,…,ek-1 for which • Each successive pair vi, vi+1 of vertices is adjacent in G, and edge ei has vi and vi+1 as end points for i=1, …, k-1; • No edge occurs more than once in the edge sequence.

  8. 8.1 Graphs • Circuit (cycle) A circuit is a path that begins and ends at the same vertex. • Simple A path is called simple if no vertex appears more than once in the vertex sequence, except possibly if v1=vk. In this case, the path is called a simple circuit.

  9. 8.1 Graphs • Connected, Disconnected & Components A graph is called connected if there is a path from any vertex to any other vertex in the graph. Otherwise, the graph is disconnected. If the graph is disconnected, the various connected pieces are called the components of the graph. p A B q s 2 5 r C E 3 4 t u D 1 6 Connected Disconnected Two components

  10. 8.1 Graphs Some important special families of graphs will be useful in our discussions. • Un (discrete graph) denote the graph with n vertices and no edges. • Ln (linear graph) denote the graph with n vertices and with edges {vi,vj} for 1≤ i <n U2 L2 U5 L5

  11. 8.1 Graphs • Kn (complete graph) denote the graph with n vertices and with an edge {vi, vj} for all i and j. • Regular If each vertex of a graph has the same degree as every other vertex, the graph is called regular. e.g. Kn and Fig. 8.6 K2=L2 K3 K4 K5

  12. 8.1 Graphs • Subgraph Support that G=(V, E, γ) is a graph. Choose a subset E1 of the edges in E and a subset V1 of the vertices in V, so that V1 contains (at least) all the end points of edges in E1. Then H=(V1,E1, γ1) is also a graph where γ1 is γ restricted to edges in E1. Such a graph H is called a subgraph of G.

  13. 8.1 Graphs • The subgraph Ge Deleting one edge and no vertices a a b b i f i f g h h g d d c c G Ge e={a,b}

  14. 8.1 Graphs • Example 8 a a b b b i i i i f f f f h h h h g g g g d d d d c c c c G

  15. 8.1 Graphs • Example 9 (Quotient graph GR) Let G be the graph (without multiple edges) of the following figure, and let R be the equivalence relation on V defined by the partition. {{a, m, i}, {b, f, j}, {c, g, k}, {d, h, l}} b a m f [m] [j] i j l k [h] [k] [a] [b] h g = d c [d] [c] GR GR

  16. 8.1 Graphs • Example 9 If S is also an equivalence relation on V defined by the partition. {{i, j, k, l}, {a, m},{f, b, c}, {d}, {g}, {h}} a b m f [a] [b] i j l k [i] g h d c [h] [g] [d] GS

  17. 8.1 Graphs • The Quotient graph Ge If e is an edge between vertex v and w in a graph G={V,E, γ}, then we consider the equivalence relation whose partition consists of {v, w} and {vi}, for each vi v, vi w. (merging v and w and leaving others alone) a a b b m m f f [i] i j l l k k g g h h d d c c G Ge e={i, j}

  18. 8.1 Graphs • Homework Ex. 6, Ex. 16, Ex. 20, Ex. 22, Ex. 23, Ex. 29

  19. 8.2 Euler Paths and Circuits • Seven Bridges of Königsberg (from Wikipedia) Question: Is it possible to walk through the city that would cross each bridge once and only once? Vertex: Land Edge: Bridge

  20. 8.2 Euler Paths and Circuits • Euler path A path in a graph G is called an Euler path if it includes every edge exactly once. • Euler circuit An Euler circuit is an Euler path that is a circuit. About Leonhard Euler: http://en.wikipedia.org/wiki/Leonhard_Euler

  21. 8.2 Euler Paths and Circuits • Example 1

  22. 8.2 Euler Paths and Circuits • Example 2 E D B C A 2 4 An Euler Path: E, D, B, A, C An Euler circuit: 5, 3, 2, 1, 3, 4, 5 3 1 5

  23. 8.2 Euler Paths and Circuits • Example 2 E 2 5 3 4 D 1 6 B C A Q: An Euler Circuit? Q: An Euler Path? A: No A: No

  24. 8.2 Euler Paths and Circuits • Example 3 Vertex: Room or Outside Edge: door Q: Is it possible to begin in a room or outside and take a walk that goes through each door exactly once?

  25. 8.2 Euler Paths and Circuits • Two Questions • Is it possible to determine whether an Euler path or Euler circuit exists without actually finding it? Theorem 1 (Euler circuit) & Theorem 2 (Euler path) • If exists Euler circuit, how to find it effectively? Fleury’s algorithm

  26. 8.2 Euler Paths and Circuits • Theorem 1 (a) If a graph G has a vertex of odd degree, there can be no Euler circuit in G E D B C 3 … 3 … 2 2 2n 2n 1 1 A 2n+1 2n+1 V of odd degree V of odd degree End at v Begin at v

  27. 8.2 Euler Paths and Circuits • Theorem 1 (b) If G is a connected graph and every vertex has even degree, then there is an Euler circuit in G. The Strategy of this proof (b) : Support there is a largest (smallest) object and construct a larger (smaller) object of the same type thereby creating a contradiction.

  28. 8.2 Euler Paths and Circuits • Proof (b) Basic Step: |V|=1, 2 is true (why?) Induction Step : |V|=1,2…k is true  |V|=k+1 is true • Assume G is connected and has more than one vertex, then there exists a simple path having the longest possible length (why?).Let its vertex sequence п0: v1 v2,…,vs. Since vs has even degree and п0 uses only one edge that has vs as a vertex, there must be an edge e not in п0 that also has vs as a vertex. If the other vertex of e is not in п0, then we can construct a simple path longer than п0(why?), which is a contradiction. Thus e has some vi as its other vertex, and therefore we have a simple circuit vi vi+1, … vs, vi in G.

  29. 8.2 Euler Paths and Circuits • Choose the longest circuit п in G, and delete all edges in п (but no vertices). Assuming there is no Euler circuits in G, then п cannot contain all edges of G (why?). Let G1 be the graph formed form G by deleting all edges in п (but no vertices). Since п is a circuit, deleting its edges will reduce the degree of every vertex by 0 or 2, so G1 is also a graph with all vertices of even degree. Choose any connected component in G1 and call this graph G2 (G2 may be G1). Then G2 has also a circuit п’ (why?).

  30. 8.2 Euler Paths and Circuits • Consider п and п’ in G case #1: if п and п’ have vertices in common, e.g. v’, then we can construct a circuit in G that is longer than п by combing п and п’ at v’ (contradiction!) Case #2: If there is no common vertex in п and п’. Then |VG2| < |VG|, then G2 has a Euler Circuit (why? ) , then G becomes not connected (why?) , which is a contradiction. Therefore, the assumption is wrong, namely, G has Euler circuit. v’ п П’ case #1

  31. 8.2 Euler Paths and Circuits • Theorem 2 (a) If a graph G has more than two vertices of odd degree, then there can be no Euler path in G Proof: Let v1, v2, v3 be vertices of odd degree. Any possible Euler path must leave (or arrive at) each of v1, v2, v3 with no way to return (or leave) since each of these vertices has odd degree. One vertex of these three vertices may be the beginning of the Euler path and another the end, but this leaves the third vertex at one end of an untraveled edge. Thus there is no Euler path.

  32. 8.2 Euler Paths and Circuits • Theorem 2 (b) If G is connected and has exactly two vertices of odd degree, there is an Euler path in G. Any Euler path in G must begin at one vertex of odd degree and end at the other. Proof: Let u and v be the two vertices of odd degree. Adding the edge {u, v} to G produces a connected graph G’ all of whose vertices have even degree. By Theorem 1(b), there is an Euler circuit п’ in G’. Omitting {u, v} from п’ produces an Euler path that begins at u (or v) and ends at v (or u).

  33. 8.2 Euler Paths and Circuits • Example 4 Each of the four vertices has degree 3. No Euler path and Euler circuit. There has exactly two vertices of odd degree. There is no Euler circuit, but there must be an Euler path. Every vertex has even degree, thus the graph must have an Euler circuit.

  34. 8.2 Euler Paths and Circuits • Bridge An edge is a bridge in a connected graph G if deleting it would create a disconnected graph. p A B q s r C E t u r is a bridge D s is a bridge t is a bridge

  35. 8.2 Euler Paths and Circuits • Algorithm FLEURY’S ALGORITHM Let G={V,E,γ} be a connected graph with each vertex of even degree. Step 1 Select an edge e1 that is not a bridge in G. Let its vertices be v1, v2. Let п be specified by Vп: v1, v2 and Eп: e1. Remove e1 from E and let G1 be the resulting subgraph of G. Step 2 Suppose that Vп: v1, v2 … vk and Eп: e1 e2 … ek-1 have been constructed so far, and that all of these edges and any resulting isolated vertices have been removed from V and E to form Gk-1. Since vk has even degree, and ek-1 ends there, there must be an edge ek in Gk-1 that also has vk as a vertex. If there is more than one such edge, select one that is not a bridge for Gk-1. Denote the vertex of ek other than vk by vk+1, Extend Vп: v1, v2 … vk vk+1 and Eп: e1 e2 … ek-1 ek. Step 3 repeat Step 2 until no edges remain in E

  36. 8.2 Euler Paths and Circuits • Example 6 Use Fleury’s algorithm to construct an Euler circuit for the following graph. B F H D A E C G

  37. 8.2 Euler Paths and Circuits • Homework Ex. 6, Ex. 12, Ex. 14, Ex. 15, Ex. 21, Ex. 25

  38. 8.3 Hamiltonian Paths and Circuits • Hamiltonian path A Hamiltonian path is a path that contains each vertex exactly once. • Hamiltonian circuit A Hamiltonian circuit is a circuit that contains each vertex exactly once except for the first vertex.

  39. 8.3 Hamiltonian Paths and Circuits • Loop and Multiple edges Loops and multiple edges are of no use in finding Hamiltonian circuits, since loops Could not be used, and only one edge can be used between any two vertices. Thus we support that any graph in this section has no loops or multiple edges.

  40. 8.3 Hamiltonian Paths and Circuits • An Example for Hamiltonian circuit

  41. 8.3 Hamiltonian Paths and Circuits • Example 1 A B 2 5 3 4 d Has Hamiltonian path But no Hamiltonian circuit D C 1 6 c e B A b Has Hamiltonian path & Hamiltonian circuit E A a E No Hamiltonian Path

  42. 8.3 Hamiltonian Paths and Circuits • Example 2 Any complete graph Kn has Hamiltonian circuits? In fact, starting at any vertex, you can visit the other vertices sequentially in any desired order. K2 K3 K4 K5 Q: How about K2? n should be larger than 2

  43. 8.3 Hamiltonian Paths and Circuits • Two Questions • Is it possible to determine whether a Hamiltonian path or circuit exists? has not been completely answered • If there must be a Hamiltonian path or circuit, it there an efficient way to find it? is still unanswered.

  44. 8.3 Hamiltonian Paths and Circuits • Theorem 1 Let G be a connected graph with n vertices, n>2, and no loops or multiple edges. G has a Hamiltonian circuit if for any two vertices u and v of G that are not adjacent, the degree of u plus the degree of v is greater than or equal to n. Corollary 1 G has a Hamiltonian circuit if each vertex has degree greater than or equal to n/2.

  45. 8.3 Hamiltonian Paths and Circuits • Theorem 2 Let the number of edges of G be m. Then G has a Hamiltonian circuit if m ≥ (n2-3n+6)/2, where n is the number of vertices Proof: Support u & v are non-adjacent vertices in G. Let deg(x) for the degree of x. Let H be the graph produced by eliminating u and v from G along with any edges that have u or v as end points. Then H has n-2 vertices and m- deg(u) –deg(v) edges. The maximum number of edges that H could possibly have is And then we have m – deg(u)-deg(v) <= ½(n2-5n+6 ) thus deg(u) +deg(v) >= n (Theorem 1 holds)

  46. 8.3 Hamiltonian Paths and Circuits • Example 3 A |V| = 8 H B For any pair of nonadjacent vertices u and v deg(u) + deg(v) = 4 < 8 G C F D Therefore, the conditions given in Theorem 1 & 2 are sufficient, but not necessary, for the conclusion. E A Hamiltonian Circuit

  47. 8.3 Hamiltonian Paths and Circuits • Traveling salesperson problem Find a Hamiltonian circuit (or path) for which the total sum of weights in the path is a minimum. For example, the vertices might represent cities, the edges, lines of transportation, and the weight of an edge, the cost of traveling along the edge. B D H 6 2 3 2 2 5 E C A 6 4 3 5 4 G F

  48. 8.3 Hamiltonian Paths and Circuits • Homework Ex. 8, Ex. 13, Ex. 18, Ex.20, Ex. 21

  49. 8.4 Transport Networks • Transport network A transport network (or network) is a connected diagraph N with the following properties: • There is a unique node, the source, that has in-degree 0, labeled the source node 1; • There is a unique node, the sink, that has out-degree 0. labeled as the sink node n if N has n nodes; • The graph N is labeled. The label, Cij, on edge (i, j) is a nonnegative number called the capacity of the edge. 4 4 3 2 Here, if (i, j) in N, then (j, i) is not 1 6 3 5 2 4 2 3 3 5 Source Sink

  50. 8.4 Transport Networks • Flows A flow in a network N is a function that assigns to each edge (i, j) of N nonnegative number Fij that does not exceed Cij. Fij denotes the amount of material passing through the edge (i,j) when the flow is F. we also require that for each node k must equal to the sum of the Fkj on edges leaving node k (conservation of flow). 2+1=3 3+0=3 (Cij, Fij ) Value of the flow (value(F)) The sum of the flows leaving the source or entering the sink (3,3) (4,2) (4,3) (2,0) 4 1 6 2 5 3 (2,1) value(F)=5 in this example (3,2) (3,2) (5,3)