graphs
play

Graphs Reading: EC 7.17.2 Peter J. Haas INFO 150 Fall Semester - PowerPoint PPT Presentation

Graphs Reading: EC 7.17.2 Peter J. Haas INFO 150 Fall Semester 2019 Lecture 15 1/ 21 Graphs Introduction The K onigsberg Bridge Problem Definitions and Terminology Graph Notation for K onigsberg Problem Eulerian Graphs Graphs


  1. Graphs Reading: EC 7.1–7.2 Peter J. Haas INFO 150 Fall Semester 2019 Lecture 15 1/ 21

  2. Graphs Introduction The K¨ onigsberg Bridge Problem Definitions and Terminology Graph Notation for K¨ onigsberg Problem Eulerian Graphs Graphs with Eulerian Trails Proofs About Graphs Lecture 15 2/ 21

  3. Introduction You have already seen lots of graphs—we will now study their abstract properties H HHH H HHT T T a 1 1 a H HTH H b 2 2 b HTT T T c 3 THH H 3 c H d 4 4 d HHT T T H TTH Directed graph TTT T Tree HS Friends College Friends Girlfriend's Friends Other Academic University Friends Friends griffsgraphs.wordpress.com/2012/07/02/a-facebook-network/ Watson drug discovery Facebook network Lecture 15 3/ 21

  4. Origins and Euler K¨ onigsberg bridge problem I Consider a walk around town: A, 6, B, 5, D, 4, A I Eulerian trail: Crosses each bridge once I Eulerian circuit: ... and comes back to starting point I Does there exist an Eulerian circuit? 7 bridges of K¨ onigsberg C A D B Abstract 7 bridges of K¨ onigsberg 1 C D 4 2 3 5 6 A B 7 K¨ onigsberg graph Lecture 15 4/ 21

  5. Origins and Euler K¨ onigsberg bridge problem I Consider a walk around town: A, 6, B, 5, D, 4, A I Eulerian trail: Crosses each bridge once I Eulerian circuit: ... and comes back to starting point I Does there exist an Eulerian circuit? 7 bridges of K¨ onigsberg C Euler’s non-existence proof I Suppose A is an intermediate vertex A D (not starting or ending) I Bridges to A must come in pairs B I So need an even number of edges Abstract 7 bridges of K¨ onigsberg I But every vertex has an odd number of edges 1 C D I Hence none of the four regions can be an interior vertex 4 2 3 5 I So Eulerian trail cannot exist 6 A B 7 K¨ onigsberg graph Lecture 15 4/ 21

  6. Eulerian Trails Proposition 1 In any graph, if there are an odd number of edges connected to a vertex x , then x cannot be an interior vertex of an Eulerian trail. Example: Explain why the following graph does not have an Eulerian trail j i h g f OP a b c d e have odd # gf vertices h , j edges , Question: Can we give conditions under which there exists an Eulerian trail? Lecture 15 5/ 21

  7. t.DE a. ! Definitions and Terminology Definitions 1. A graph G consists of a set E of edges and a set V of vertices (also called nodes). I An edge is associated with one or two vertices, called endpoints. I Two nodes joined by an edge are called adjacent nodes. I An edge with one vertex is called a loop. I Two edges having the same endpoints are called multiple edges or parallel edges. 2. A walk is a sequence v 1 e 1 v 2 e 2 · · · v n e n v n +1 of alternating vertices and edges. I Each edge in the list lies between its endpoints. I If beginning and end vertices are the same, the walk is closed. I The length of a walk is the number of edges ( n in the above example). I A walk of length 0 is called a trivial walk. 3. A trail is a walk with no repeated edges; a path is a walk with no repeated vertices. I A circuit is a closed trail I A circuit having one vertex and no edges is called a trivial circuit. • I A trail or circuit is Eulerian if it uses every edge in the graph. I A cycle is a nontrivial circuit in which the only repeated node is the first/last one. Lecture 15 6/ 21

  8. Definitions: Example ? 1 A 3 2 4 B C 5 1. The graph has 3 nodes and 5 edges 2. Edge 1 is a loop; edges 3 and 4 are parallel 3. Some walks in the graph: (a) B, 5, C, 5, B, 2, A, 2, B is a closed walk that repeats edge 5 (so not a trail) (b) A, 2, B, 5, C is a path (no repeated vertices) (c) B is a trivial walk and a trivial circuit (d) A, 1, A, 2, B, 5, C, 3, A is a circuit starting and ending at A (e) A, 2, B, 5, C, 3, A, 1, A, 4, C is an Eulerian trail (f) The first part of (e), A, 2, B, 5, C, 3, A, is a cycle—unlike (d), node A appears only twice Challenge: Add one edge to the graph to create an Eulerian circuit Lecture 15 7/ 21

  9. Graphs in Applications The graph that you use depends upon the application 702 Madrid Paris Madrid Paris 812 31 3421 17 117 1703 3913 271 2321 Rome London Rome London G1: Simple Graph G2: Directed Graph with Parallel Edges Flight planning I How do I get from Madrid to London? (G1 or G2) I Note: For G1, it su ffi ces just to list the sequence of vertices I What flights will take me from Madrid to London? (G2) Lecture 15 8/ 21

  10. More Graph Notation Definitions 1. A simple graph is a graph with no loops and no multiple (i.e., parallel) edges. 2. Notation [ a , b ]: an undirected edge with endpoints a and b 3. Notation ( a , b ): an directed edge going from a to b 702 Madrid Paris Madrid Paris 812 31 3421 17 117 1703 3913 271 2321 Rome London Rome London G1: Simple Graph G2: Directed Graph with Parallel Edges Examples I G1 edges are: [Madrid, Paris], [London, Paris], [Madrid, Rome], [Paris, Rome] I G2 directed edges include: (Rome, Paris), (Paris, Rome), (Rome, Madrid) I Note: There is never any ambiguity in a simple graph Lecture 15 9/ 21

  11. If e- • v Graph Notation for K¨ onigsberg Problem Definitions 1. An edge e is incident with a node v if and only if v is an endpoint of e 2. The degree of node v , denoted deg( v ), is the number of times v appears as the endpoint of an edge. (It equals the number of edges that are incident with v , except that loops are counted twice.) 3. A graph G is connected if there is a walk between any two nodes. 4. A graph H is is a subgraph of a graph G if all nodes and edges in H are also nodes and edges in G . 5. A connected component of a graph G is a connected subgraph H of G such that no other connected subgraph of G containing H exists. Lecture 15 10/ 21

  12. Graph Notation for K¨ onigsberg Problem Definitions 1. An edge e is incident with a node v if and only if v is an endpoint of e 2. The degree of node v , denoted deg( v ), is the number of times v appears as the endpoint of an edge. (It equals the number of edges that are incident with v , except that loops are counted twice.) 3. A graph G is connected if there is a walk between any two nodes. 4. A graph H is is a subgraph of a graph G if all nodes and edges in H are also nodes and edges in G . 5. A connected component of a graph G is a connected subgraph H of G such that no other connected subgraph of G containing H exists. Example I The degree of node 3 is 4: it 1 2 6 appears in [1 , 3], [3 , 2], [5 , 3], and [3 , 4]. The degree of node 6 is 3 I There is no walk from node 4 to 5 7 node 6, so the graph is not connected I The graph has two connected 8 3 4 components Lecture 15 10/ 21

  13. K¨ onigsberg Graph Notation: Example Definitions 1. An edge e is incident with a node v if and only if v is an endpoint of e 2. The degree of node v , denoted deg( v ), is the number of times v appears as the endpoint of an edge. (It equals the number of edges that are incident with v , except that loops are counted twice.) 3. A graph G is connected if there is a walk between any two nodes. 4. A graph H is is a subgraph of a graph G if all nodes and edges in H are also nodes and edges in G . 5. A connected component of a graph G is a connected subgraph H of G such that no other connected subgraph of G containing H exists. ÷ : " Example . I What is the degree of node 1? 1 2 6 I Find an Eulerian trail in the component on the right 7 5 I Find an Eulerian circuit in the component on the left I Is the red subgraph a connected 3 4 8 component? Lecture 15 11/ 21

  14. Eulerian Graphs Definition A graph G is Eulerian if it contains an Eulerian circuit. Theorem 2 Let G be a connected graph. The graph G is Eulerian if and only if every node in G has even degree. The proof of this theorem uses induction. The basic ideas are illustrated in the next example. We reduce the problem of finding an Eulerian circuit in a big graph to finding Eulerian circuits in several smaller graphs. Lecture 15 12/ 21

  15. How to Find an Eulerian Circuit 13 12 13 12 14 14 14 1 11 10 1 11 11 10 8 8 8 2 2 7 9 7 7 9 3 3 3 4 6 4 6 5 5 Given a connected graph G with all nodes of even degree: 1. Find any circuit C and form a graph G 0 by removing from G all edges in the circuit C Lecture 15 13/ 21

  16. How to Find an Eulerian Circuit 13 12 13 12 14 14 14 1 11 10 1 11 11 10 8 8 8 2 2 7 9 7 7 9 3 3 3 for 4 6 4 6 5 5 Given a connected graph G with all nodes of even degree: 1. Find any circuit C and form a graph G 0 by removing from G all edges in the circuit C 2. Observe that G 0 is not connected; call its components H 1 and H 2 Lecture 15 13/ 21

  17. How to Find an Eulerian Circuit 13 12 13 12 14 14 14 1 11 10 1 11 11 10 8 8 8 2 2 7 9 7 7 9 3 3 3 4 6 4 6 5 5 Given a connected graph G with all nodes of even degree: 1. Find any circuit C and form a graph G 0 by removing from G all edges in the circuit C 2. Observe that G 0 is not connected; call its components H 1 and H 2 3. H 1 and H 2 are smaller connected graphs, with all nodes having even degree (a) H 1 has an Eulerian circuit C 1 = 3 , 4 , 5 , 6 , 7 , 11 , 12 , 13 , 6 , 3 , 11 , 13 , 14 , 3 (b) H 2 has an Eulerian circuit C 2 = 8 , 9 , 10 , 8 Lecture 15 13/ 21

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend