Lecture 8: PATHS, CYCLES AND CONNECTEDNESS

Similar documents
Lecture 3: Graphs and flows

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE

Lecture 10 Graph algorithms: testing graph properties

Fundamental Properties of Graphs

Exercise set 2 Solutions

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.

Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1

{ 1} Definitions. 10. Extremal graph theory. Problem definition Paths and cycles Complete subgraphs

Chapter 2 Graphs. 2.1 Definition of Graphs

implementing the breadth-first search algorithm implementing the depth-first search algorithm

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

Math 776 Graph Theory Lecture Note 1 Basic concepts

Matching Theory. Figure 1: Is this graph bipartite?

11.2 Eulerian Trails

5.1 Min-Max Theorem for General Matching

Math 778S Spectral Graph Theory Handout #2: Basic graph theory

Matchings in Graphs. Definition 1 Let G = (V, E) be a graph. M E is called as a matching of G if v V we have {e M : v is incident on e E} 1.

8.2 Paths and Cycles

Section 3.1: Nonseparable Graphs Cut vertex of a connected graph G: A vertex x G such that G x is not connected. Theorem 3.1, p. 57: Every connected

LECTURE 17 GRAPH TRAVERSALS

Homework Assignment #3 Graph

Number Theory and Graph Theory

CS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019

K 4 C 5. Figure 4.5: Some well known family of graphs

CPS 102: Discrete Mathematics. Quiz 3 Date: Wednesday November 30, Instructor: Bruce Maggs NAME: Prob # Score. Total 60

Scribes: Romil Verma, Juliana Cook (2015), Virginia Williams, Date: May 1, 2017 and Seth Hildick-Smith (2016), G. Valiant (2017), M.

COL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE

Copyright 2000, Kevin Wayne 1

Lecture 4: Walks, Trails, Paths and Connectivity

Graph Representations and Traversal

Algorithms and Theory of Computation. Lecture 3: Graph Algorithms

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.

W4231: Analysis of Algorithms

Chapter 4. Relations & Graphs. 4.1 Relations. Exercises For each of the relations specified below:

Theorem 3.1 (Berge) A matching M in G is maximum if and only if there is no M- augmenting path.

Two Characterizations of Hypercubes

Computer Science 280 Fall 2002 Homework 10 Solutions

CS 220: Discrete Structures and their Applications. graphs zybooks chapter 10

Advanced Combinatorial Optimization September 17, Lecture 3. Sketch some results regarding ear-decompositions and factor-critical graphs.

Homework 2. Sample Solution. Due Date: Thursday, May 31, 11:59 pm

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

Math 170- Graph Theory Notes

Graph Algorithms Using Depth First Search

Graph Theory S 1 I 2 I 1 S 2 I 1 I 2

Ma/CS 6b Class 5: Graph Connectivity

Lecture 20 : Trees DRAFT

Graph theory - solutions to problem set 1

This course is intended for 3rd and/or 4th year undergraduate majors in Computer Science.

Algorithm Design and Analysis

V10 Metabolic networks - Graph connectivity

Assignment 4 Solutions of graph problems

Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret

Discrete Wiskunde II. Lecture 6: Planar Graphs

Some Upper Bounds for Signed Star Domination Number of Graphs. S. Akbari, A. Norouzi-Fard, A. Rezaei, R. Rotabi, S. Sabour.

1 Matchings in Graphs

Augmenting Trees so that Every Three Vertices Lie on a Cycle

Math 485, Graph Theory: Homework #3

HW Graph Theory SOLUTIONS (hbovik)

Assignment # 4 Selected Solutions

1 Connected components in undirected graphs

CSC 172 Data Structures and Algorithms. Lecture 24 Fall 2017

Discrete Mathematics, Spring 2004 Homework 8 Sample Solutions

CSE 417: Algorithms and Computational Complexity. 3.1 Basic Definitions and Applications. Goals. Chapter 3. Winter 2012 Graphs and Graph Algorithms

Ma/CS 6b Class 4: Matchings in General Graphs

[Ramalingam, 4(12): December 2017] ISSN DOI /zenodo Impact Factor

Graph Theory. Connectivity, Coloring, Matching. Arjun Suresh 1. 1 GATE Overflow

1 The Traveling Salesperson Problem (TSP)

Graph Theory Day Four

Abstract. A graph G is perfect if for every induced subgraph H of G, the chromatic number of H is equal to the size of the largest clique of H.

Lecture 10: Strongly Connected Components, Biconnected Graphs

The Restrained Edge Geodetic Number of a Graph

CSE 21 Mathematics for Algorithm and System Analysis

CS781 Lecture 2 January 13, Graph Traversals, Search, and Ordering

Discrete mathematics II. - Graphs

Graph Theory: Introduction

Lecture notes on: Maximum matching in bipartite and non-bipartite graphs (Draft)

12/5/17. trees. CS 220: Discrete Structures and their Applications. Trees Chapter 11 in zybooks. rooted trees. rooted trees

Greedy Approximations

by conservation of flow, hence the cancelation. Similarly, we have

Modules. 6 Hamilton Graphs (4-8 lectures) Introduction Necessary conditions and sufficient conditions Exercises...

1 Bipartite maximum matching

Figure 1: A directed graph.

MAL 376: Graph Algorithms I Semester Lecture 1: July 24

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Chapter 3. Graphs. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

CS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review

Chapter 3: Paths and Cycles

Algorithms: Lecture 10. Chalmers University of Technology

3.4 Testing Bipartiteness

Plan. CMPSCI 311: Introduction to Algorithms. Recall. Adjacency List Representation. DFS Descriptions. BFS Description

Module 11. Directed Graphs. Contents

Undirected Graphs. DSA - lecture 6 - T.U.Cluj-Napoca - M. Joldos 1

CONNECTIVITY AND NETWORKS

Discrete mathematics

Hamiltonian cycles in bipartite quadrangulations on the torus

arxiv: v1 [math.co] 28 Nov 2016

CS521 \ Notes for the Final Exam

Transcription:

Discrete Mathematics August 20, 2014 Lecture 8: PATHS, CYCLES AND CONNECTEDNESS Instructor: Sushmita Ruj Scribe: Ishan Sahu & Arnab Biswas 1 Paths, Cycles and Connectedness 1.1 Paths and Cycles 1. Paths Definition 1.1 A walk is a sequence of vertices and edges. e.g. In Figure 1 v 1 e 1 v 2 e 2 v 3, v 1 e 1 v 2 e 2 v 3 e 3 v 4 are among the walks present in the graph G1. Definition 1.2 A path is a walk with no repeated vertices. e.g. In Figure 2 v 1 e 1 v 2 e 2 v 3 e 3 v 4 is a path whereas v 1 e 1 v 2 e 4 v 5 e 5 v 4 e 3 v 3 e 2 v 2 is not a path in graph G2. Definition 1.3 A trail is a walk with no repeated edges. e.g. In Figure 2 v 1 e 1 v 2 e 4 v 5 e 5 v 4 e 3 v 3 e 2 v 2 e 6 v 6 is a trail. A walk or trail is closed if the first vertex is equal to the last vertex. 2. Cycles Definition 1.4 A cycle is a closed trail in which the first vertex = last vertex is the only vertex that is repeated. e.g. Figure 3 shows cycles with three and four vertices. A graph is acyclic if it does not contain a cycle. Figure 1: Graph G 1 8-1

Figure 2: Graph G 2 Figure 3: C 3 : Cycle with three vertices; C 4 : Cycle with four vertices 1.2 Graph Traversal The goal of the graph traversal is to visit all the nodes of a given graph in a particular manner. The two popular algorithms are breadth first search and depth first search. 1. Breadth First Search (BFS) BFS visits nodes in the order of their distance from the starting node. It traverses the breadth of any particular path before exploring its depth. [2] [5] Algorithm [2] Input: An unweighted graph and a start vertex u. 8-2

Idea: Maintain a set R of vertices that have been reached but not searched and a set S of vertices that have been searched. The set R is maintained as a First-In First-Out list (queue), so the first vertices found are the first vertices explored. Initialization: R = u, S = Φ, d(u, u) = 0 Iteration: As long as R Φ, we search from the first vertex v of R. The neighbours of v not in S R are added to the back of R and assigned distance d(u, v)+1, and then v is removed from the front of R and placed in S. e.g. In the graph G 3 in Figure 4 one breadth-first search from u finds the vertices in the order u, a, g, b, f, c, d, e. 2. Depth First Search (DFS) DFS visits the child nodes before visiting the sibling nodes; that is, it traverses the depth of any particular path before exploring its breadth. [5] In DFS, we explore always from the most recently discovered vertex that has unexplored edges. We maintain the list of vertices to be searched as a Last-In First-Out stack rather than a queue. [2] Algorithm [4] Input: An unweighted graph and a start vertex u. Procedure: Maintain a set R of vertices that have been reached but not discovered and a set S of vertices that have been discovered. The set R is maintained as a Last-In First-Out stack, so the most recently found vertiex is the first vertex to be explored. Add u to R. As long as R Φ, following steps are repeated: (a) Take out the last-in vertex v. (b) If v / S then place it in S and add all adjacent vertices w, if present, to R. e.g. In the graph G 3 in Figure 4 one depth-first search from u finds the vertices in the order u, a, b, c, d, e, f, g. Figure 4: Graph G 3 8-3

Question: How to find whether a cycle is present in the graph? Answer: Traverse the graph keeping track of vertices visited. If a vertex is reached again, a cycle is present. 1.3 Connections in Graphs 1. Connected Graphs Definition 1.5 A graph is connected if it has a u-v path for every pair of vertices. u, v V (G) Definition 1.6 The components of a graph are its maximal connected subgraphs. Definition 1.7 A cut-edge(cut-vertex) is an edge(vertex), which when removed increases the number of components. e.g. Figure 5 shows a connected graph with a cut-edge and the components formed after its removal. 2. Distances in Graphs Definition 1.8 The distance between a pair of vertices is the length of the shortest path between them. Definition 1.9 The diameter of a graph G is the longest shortest path over all the vertices of G. e.g. Figure 6 shows a graph with diameter 4. Definition 1.10 The eccentricity of a vertex v, denoted by ɛ(v) is the maximum distance from v to any other vertex in the graph. Definition 1.11 The radius of a graph G is the minimum of the eccentricities of its vertices. e.g. Figure 7 shows a graph with radius 2. 8-4

Figure 5: (a) A connected graph with a cut-edge v x v y ; (b), (c) The two components after removing the cut-edge. Figure 6: A graph with diameter 4. i b, j d have the longest shortest path of 4. 8-5

Figure 7: A graph with radius 2. f has the minimum eccentricity of 2. 2 Proofs Theorem 2.1 A graph is connected if and only if for every partition of its vertices into two non empty sets, there is an edge with end points in both sets. Proof. [3] Let G be a connected graph. Given a partition of V (G) into non empty sets S, T. Choose u ɛ S and v ɛ T. Since G is connected, G has a u, v -path P. After its last vertex in S, P has an edge from S to T. We show that if G is not connected then for some partition there is no edge across. In particular, if G is disconnected, then let it be a component of G. Since H is a maximal connected sub graph of G and the connection relation is transitive, there can not be an edge with one end point in V (H) and the other end point outside. Thus for the partition of V (G) into V (H) and V (G) V (H) there is no edge with end points in both of these sets. Theorem 2.2 An edge of a graph is cut edge if and only if it does not belong to any cycle. Proof. [2] Let, e be an edge in a graph G with end points x and y, and let H be the component containing e. Since definition of e affects no other component, it suffices to prove that H e is connected if and only if e belongs to a cycle. See Figure 8 First, suppose that H e is connected. This implies that H e is contains an x, y-path and this path completes a cycle with e. Now, suppose that e lies in a cycle C. Choose u, v ɛ V (H). Since H is connected, H has a u, v-path P. If P does not contain e, then P exist in H e. If P contains e, suppose by symmetry that x is between u and y on P. Since H e contains a u, x-path along P, an x, y-path along C and a y, v-path along P, the transitivity of the connection relation implies that H e has a u, v-path. We did this for all u, v ɛ V (H), so H e is connected. 8-6

Figure 8: Theorem 2.2 Theorem 2.3 (König[1936]) A graph is bipartite if and only if it has no odd cycle. Proof. [2] N ecessity. Let G be a bipartite graph. Every walk alternates between the two sets of a bipartition, so every return to the original partite set happens after an even number of steps. Hence G has no odd cycle. See Figure 9 Figure 9: Theorem 2.3 Sufficiency. Let G be a graph with no odd cycle. We prove that G is bipartite by constructing a bipartition of each non trivial component. Let, u be a vertex in a nontrivial component H. For each vɛv (H), let f(v) be the minimum length of a u, v-path. Since H is connected, f(v) is defined for each vɛv (H). Let, X = vɛv (H) : f(v) is even and X = vɛv (H) : f(v) is odd. An edge v, v within X or Y would create a closed odd walk using a shortest u, v-path, the edge vv, and the reverse of a shortest u, v-path. Such a walk must contain an odd cycle(because every closed odd walk contains an odd cycle)which contradicts our hypothesis. Hence X and Y are independent sets. Also X Y = V (H), so H is an X Y - bigraph. Theorem 2.4 If a graph has no odd cycle, then it is bipartite. Proof. [1] Pick up a random vertex v in G, calculate the length of the shortest simple path from v to any other node, call this value distance from v, and divide nodes into 2 groups 8-7

according to the parity of their distance to v. If we can prove that nodes belong to the same group can not be adjacent, then we know that we actually get a partition of the G that fulfill the definition of bipartite graph. Now, to introduce contradiction, assume two nodes x, y with both even or odd distance from v are adjacent, then the shortest simple path < v, x >, < v, y > and edge x, y contains a cycle with odd length, which is contradictory to that G has no cycles of odd length. In other words, nodes both with even or odd distance from v can not be adjacent, which is exactly what we need. Again to prove that < v, x > and < v, y > together with < x, y > contains a cycle with odd length is obvious when < v, x > and < v, y > are disjoint. When that s not the case, let s give the last node shared by < v, x > and < v, y > the name v. So the three nodes v, x, y forms a cycle with length L = len(< v, x >)+len(< v, y >)+1 = len(< v, x >)+len(< v, y >) 2len(< v, v >)+1. where len() means the length of the shortest path.as len(< v, x >) and len(< v, y >) are both even or odd, then L must be odd. Therefore, in both cases, disjoint or not, < v, x >, < v, y > and < x, y > contains a cycle with odd length, which is again contradictory. So that concludes our proof that G is bipartite. Theorem 2.5 Suppose G has a vertex set (v 1, v 2...v n ) with n 3, if it has at least two of its sub graphs ( G v 1, G v 2,...G v n ) are connected then G is connected. Proof. Let, us say that G is not connected i.e there exist at least one vertex u ɛ G from which there is no path to at least another vertex v ɛ G. See Figure 10 Suppose we take two random vertices v i and v j for which we have two different connected sub graphs (G v i ) and (G v j ). Now, in case of the sub graph (G v i ), there exist a path from the vertex v j to all other vertices because it is connected. Again, in case of the sub graph (G v j ), there exist a path from the vertex v i to all other vertices because it is also connected. So, if we take any other common vertices of these two sub graphs (say v k ), then we have a path from v i to v k and from v k to v j. From that we can conclude that we can also have a path from v i to v j. As we have chosen v i and v j randomly, so that is also true for all the other vertices, i.e there exist a path between every pair of vertices. That concludes our proof that the graph G is connected. 8-8

Figure 10: Theorem 2.5 References [1] StackExchange. If a graph has no cycles of odd length, then it is bipartite: is my proof correct? http://math.stackexchange.com/questions/61920/ if-a-graph-has-no-cycles-of-odd-length-then-it-is-bipartite-is-my-proof-correc, [Online, accessed 28 August, 2014]. [2] Douglas B. West. Introduction To Graph Theory. Pearson Prentice Hall, 2 edition. [3] Douglas B. West. Introduction To Graph Theory Solution Manual. Summer 2005 edition. [4] Wikipedia. Depth-first Search. http://en.wikipedia.org/wiki/depth-first_ search, [Online, accessed 28 August, 2014]. [5] Wikipedia. Graph Traversal. http://en.wikipedia.org/wiki/graph_traversal, [Online, accessed 28 August, 2014]. 8-9