chapter 2 walks
play

Chapter 2. Walks (Chapters 1.7, 2.12.6) Prof. Tesler Math 154 - PowerPoint PPT Presentation

Chapter 2. Walks (Chapters 1.7, 2.12.6) Prof. Tesler Math 154 Winter 2020 Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 1 / 64 Chapter 1.7: Subgraphs Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 2 / 64 Subgraphs 1 5 2 5


  1. Chapter 2. Walks (Chapters 1.7, 2.1–2.6) Prof. Tesler Math 154 Winter 2020 Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 1 / 64

  2. Chapter 1.7: Subgraphs Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 2 / 64

  3. Subgraphs 1 5 2 5 2 4 3 4 3 G G’ Let G = ( V , E ) be a graph. V ′ ⊆ V , E ′ ⊆ E , A subgraph of G is G ′ = ( V ′ , E ′ ) where and the edges of E ′ only involve vertices of V ′ . If we remove a vertex v from G , we also must remove all edges incident with it. We may also remove edges, even if their vertices remain. For multigraphs and directed graphs, it’s similar. Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 3 / 64

  4. Set difference We’ll look at several constructions of subgraphs, based on specifying either which vertices/edges to remove or which to keep. Let A and B be sets. Their set difference is A \ B = A ∩ B c = { x ∈ A : x � B } { 1 , 2 , 3 , 4 , 5 , 6 , 7 } \ { 3 , 5 , 7 , 9 , 11 } = { 1 , 2 , 4 , 6 } Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 4 / 64

  5. Subtracting vertices from a graph 1 5 2 5 2 4 3 3 G G − {1,4} Let X be a subset of the vertices of G . G − X is the subgraph of G obtained by removing those vertices and all edges incident with them: Vertices: V ( G ) \ X Edges: { e ∈ E ( G ) : e ∩ X = ∅ } = all edges of G not incident to any vertices in X Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 5 / 64

  6. Induced subgraph (only keep certain vertices) 1 5 2 5 2 4 3 4 3 G G[{2,3,4,5}] Let X be a subset of the vertices of G . The induced subgraph G [ X ] is G − ( V ( G ) \ X ) : the vertices are X , and keep the edges that only involve X . Vertices: X Edges: { e ∈ E ( G ) : e ⊂ X } Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 6 / 64

  7. Subtracting edges from a graph 1 1 5 2 5 2 4 3 4 3 G G − { {1,2}, {4,5} } Let L be a subset of the edges of G . G − L is the subgraph of G with the same vertices as G , but edges L removed. Vertices: V ( G ) Edges: E ( G ) \ L On the right, vertex 1 is an isolated vertex : a vertex of degree 0 . Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 7 / 64

  8. Subgraph spanned by edges (only keep those edges) 1 5 2 5 2 4 3 3 G L = { {2,5}, {3,5} } Let L be a subset of the edges of G . The subgraph of G spanned by L has edge set L , and all vertices incident with edges in L : � Vertices: Edges: e L e ∈ L Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 8 / 64

  9. Spanning subgraph 1 1 5 2 5 2 4 3 4 3 G G’ A similar but different term: a spanning subgraph of G is any subgraph that has the same vertices as G . Vertices: V ( G ) Edges: Any subset of E ( G ) Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 9 / 64

  10. Neighborhood of a set of vertices (figure from Verstraete textbook) Let X be a subset of the vertices of G . The neighborhood of X is all vertices of G that are outside X and adjacent to at least one vertex in X : N ( X ) = { y ∈ V ( G ) \ X : { x , y } ∈ E ( G ) for some x ∈ X } N ( { 1 , 2 , 3 } ) = { 5 , 6 , 7 , 9 , 10 } Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 10 / 64

  11. Contraction of a graph G / { 1 , 2 , 3 , 5 , 7 } G (figure from Verstraete textbook) Let X be a subset of the vertices of G . The contraction G / X is a new graph obtained as follows: Form G − X by removing X and incident edges. Add a new vertex x . Add new edges connecting x to each vertex of N ( X ) . This is also called contracting X to a vertex x . This is not a subgraph of G , but it makes use of subgraphs. Also note the different notations A \ B vs. G / X . Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 11 / 64

  12. Chapter 2: Walks Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 12 / 64

  13. Walks — Example: Transit map 1 Route c from station 1 to station 2 a c b Route f from station 2 to station 5 6 e d 5 2 f Route g from station 5 to station 4 g h Route i from station 4 to station 3 i 4 3 A transit map is shown above, with a route from station #1 to #3. This is called a walk in the graph. It starts at 1 and ends at 3, so it’s also called a 1,3-walk. Represent it by listing the sequence of vertices and/or edges: vertices & edges: 1 , c , 2 , f , 5 , g , 4 , i , 3 (not usually listed this way) vertices: 1 , 2 , 5 , 4 , 3 ( 5 vertices) edges: c , f , g , i ( 4 edges) The length of a walk is the number of edges, 4 . Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 13 / 64

  14. Walks 1 a c b 6 e d 5 2 f g h i 4 3 Trace along edges from vertex x to y , without lifting your pen. A walk from vertex x to y is a sequence of edges, each connected to the next by a vertex: e 1 = { x , v 1 } e 2 = { v 1 , v 2 } e 3 = { v 2 , v 3 } · · · e k = { v k − 1 , y } In a directed graph, edge directions must be respected: e 1 = ( x , v 1 ) e 2 = ( v 1 , v 2 ) e 3 = ( v 2 , v 3 ) · · · e k = ( v k − 1 , y ) The length of the walk is the number of edges, k (not the number of vertices, k + 1 ). Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 14 / 64

  15. Walks Note: Some authors use these terms differently 1 1 1 1 a c a c a c a c b b b b d 6 e 6 e 6 e 6 e d d d 5 f 2 5 2 5 2 5 2 f f f g h g h g h g h i i i i 4 3 4 3 4 3 4 3 Walk Trail Path Tour In a walk , edges and vertices may be re-used. A trail is a walk with all edges distinct. A path is a walk with all vertices and edges distinct. A walk/trail/path is open if the start and end vertices are different, and closed if they’re the same (this is allowed in a closed path, but no other vertices may be repeated). A tour is a closed trail (all edges distinct). A cycle is a closed path (all vertices and edges distinct, apart from start = end). Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 15 / 64

  16. Example: Paths in a computer network PC1 PC2 Modem ISP Remote server PC3 Printer Hard drive For PC1 to print a page from a website, first it retrieves the page Remote server → · · · → ISP → Modem → PC1 and then it sends it to the printer PC1 → Modem → Printer PC3 can directly print on the printer w/o going through the Modem. For PC1 to read a file from the hard drive, it goes through a path Hard drive → PC3 → Modem → PC1 Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 16 / 64

  17. Example: Graph of friends Irene Gina Harry Dan Emily Frank Cindy Amy Bob The length of a walk/trail/path is the number of edges in it. The distance between vertices is the length of the shortest path. Amy’s friends: Bob, Cindy, Dan, Emily Each is distance 1 from Amy. Amy and Frank’s mutual friends: Bob, Cindy They are the middle vertex on a path of length 2 from Amy to Frank. Amy’s friends of friends: Frank, Gina, Irene Each is distance 2 from Amy. “Six degrees of separation”: A popular concept is that everyone is � 6 steps away from everyone in the world. (It’s probably false.) Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 17 / 64

  18. Bipartite graph This graph is bipartite. The vertices are split into two parts, A (green) and B (black), and edges are only allowed when the two vertices are in different parts. Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 18 / 64

  19. Cycle in a bipartite graph A cycle in a bipartite graph must have even length: A cycle has consecutive vertices v 0 , v 1 , . . . , v n with v 0 = v n . For a cycle in a bipartite graph, the vertices alternate coming from A , B , A , B , . . . or B , A , B , A , . . . . Since v 0 = v n , they’re both in A or both in B , so n is even. Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 19 / 64

  20. Connected graph 1 component 2 components 2 components An undirected graph is connected if for all vertices u , v , there is a path from u to v . Otherwise, it’s disconnected . The graph on the left is connected. The others are disconnected. A graph may be split into connected components . Partition the graph into subgraphs. Vertices u , v are in the same connected component iff there is a path from u to v . Each isolated vertex is in its own component. Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 20 / 64

  21. Hamiltonian paths / cycles Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 21 / 64

  22. Walks using all vertices or all edges 1 1 1 5 2 5 2 5 2 4 3 4 3 4 3 Hamiltonian path Hamiltonian cycle Eulerian tour 1,2,3,4,5 1,2,3,4,5,1 1,2,3,4,5,1,3,5,2,4,1 A Hamiltonian path is a path that uses every vertex exactly once. An Eulerian trail is a trail that uses every edge exactly once. Note: Euler is pronounced “oiler.” Closed versions: Hamiltonian cycle and Eulerian tour . A Hamiltonian cycle starts and ends at the same vertex, but all other vertices are used just once. These are used in many algorithms in Computer Science. While the descriptions are similar, there are good solutions for the Eulerian problem but not the Hamiltonian problem. Prof. Tesler Ch. 2. Walks Math 154 / Winter 2020 22 / 64

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