MAL 376: Graph Algorithms I Semester 2014-2015 Lecture 1: July 24 Course Coordinator: Prof. B. S. Panda Scribes: Raghuvansh, Himanshu, Mohit, Abhishek Disclaimer: These notes have not been subjected to the usual scrutiny reserved for formal publications. They may be distributed outside this class only with the permission of the Course Coordinator. This lecture's notes describe the concept of depth first search and biconnectivity in graphs. They start by introducing graphs, their preliminaries and other notations that would be used later on to finally give an algorithm to enumerate all the biconnected components in the graph using depth first search. 1.1 Preliminaries A graph is a set of vertices V and edges E ⊆ V × V . A graph is called simple if it has no multiple edges (multiple edges between the same pair of vertices) and self loops (an edge from a vertex to itself). A graph is considered to be undirected if there is no sense of ordering in the vertices of an edge i.e. an edge from a to b is also an edge from b to a, otherwise it is said to be directed. An edge (u; v) is said to be incident on the vertices u and v. The degree of a vertex is the number of edges incident on it. For directed graphs, there are two degrees, an in-degree and a out-degree for every vertex. Henceforth, unless otherwise specified, a use of the term graph would mean an undirected, simple graph. Pictorially, a graph with V = fr; s; u; v; wg and E = f(r; s); (r; v); (r; w); (s; v); (u; v); (u; w)g would be drawn as shown below: Figure 1.1: A Graph A graph (V 0;E0) is said to be a subgraph of another graph (V; E) if V 0 ⊆ V and E0 ⊆ E. A path is an sequence of edges that connect distinct vertices. A graph is said to be connected if there is a path between any pair of vertices, otherwise it is said to be disconnected. A graph can always be broken down into a set of connected subgraphs that are known as connected components of a graph. We will use the `Big-Oh' \O" in our analysis of algorithms. By saying that an algorithm is O(f(n)) in some 1-1 1-2 Lecture 1: July 24 input parameter n, we mean that as there exist constants c > 0 and n0 > 0 such that 8n > n0, the total units of time the algorithm would take to terminate will never be more than c ∗ f(n). 1.2 Definitions Walk: A walk in the graph G = (V; E) is a finite sequence of the form vi0 ; ej1 ; vi1 ; ej2 ; :::; ejk ; vik ; which consists of alternating vertices and edges of G such that all edges e in the sequence are incident on the vertices just before and just after in the sequence. vi0 is said to be the initial vertex and vik is said to be the terminal vertex. k is called the length of the walk. Trail:Trail is a walk in which there are no repeated edges. Path:Path is a walk in which there are no repeated vertices. Circuit:A circuit is a trail that begins and ends at the same vertex. Cycle: A cycle is a path that begins and ends at the same vertex. Tree: A graph with no cycles is termed a tree. A tree is said to be rooted if one special vertex has been designated the root and unrooted otherwise. Parent: A vertex v is a parent of w in a rooted tree v comes just before w in a path from root to w in the tree. Ancestor: A vertex v is a ancestor of w in a rooted tree if a path from root to w in the tree includes v. Descendant: A vertex v is a descendant of w if w is an ancestor of v in the tree. 1.3 Depth-first Search One of the most basic algorithm to traverse a graph (i.e., to visit all it's vertices and/or edges) is the depth first search(DFS). The basic idea of DFS is, as the name suggests, to search \deeper" in the graph wherever possible. It explores edges out of the most recently discovered vertex v that still has unexplored edges leaving it. After all the edges of v have been explored, the search \backtracks" to explore all the yet unexplored edges leaving the vertex from which v was discovered. When it discovers all the vertices that are reachable from the source vertex, it stops. For example, one of the possible ways in which the vertices of a graph could be explored by DFS is shown in Fig 1.2. The numbers indicate the order in which the vertex is visited. Figure 1.1: A DFS traversal For understanding DFS better let us define the concept of colouring of vertices. If a vertex is coloured white then it means it is not visited before. If it is coloured black then it has already been discovered. Lecture 1: July 24 1-3 Following is the pseudo code for DFS: DFS (G): for each vertex u 2 G:V u:color = WHITE for each vertex u 2 G:V if u:color == WHITE DFS-VISIT (G; u) DFS-VISIT (G , u): for each vertex v 2 G:Adj[u] if v:color == WHITE DFS-VISIT (G; v) u:color = BLACK Any implementation of the above algorithm defines a subset T of edges E. A edge (v; w) is said to be in T if while exploring this edge one of the vertices w was yet to be explored. This subset of edges constitutes a tree called the DFS-tree. The DFS-tree is rooted with its root at the `source' vertex of the DFS. It is proved in the following theorem that any of the non-tree edges of G connect an ancestor to a descendant in the DFS-tree. Theorem 1.1 All non-tree edges of G connect an ancestor to a descendant in the DFS-tree. Proof: Consider an edge (v; w) of the graph G. Without loss of generality, we can assume that v was visited before w during the DFS. That means when the DFS was called on v, the vertex w was still white. Also, DFS at v would not stop until all its neighbours were black. Since, w is a neighbour of v it implies that it would also be black after DFS at v is over and hence be a descendant of v in the DFS-tree. 1.4 Biconnectivity Having had an idea of depth-first search, we will now start with biconnectivity. As the name suggests, biconnectivity is like `connected twice over'. A more formal definition is as follows. A connected graph G is said to be biconnected if for all distinct triples of vertices v, w and a, there exists a path connecting v and w that does not go through a. In other words, the connection between v and w does not solely depend on a. There are other paths as well. Infact, every path has such `another' path to reach from its source to the destination. It directly follows from this that removal of any vertex (along with its incident edges) of G would split G into two connected components. This is true as we can take this vertex as our `a' and for any other pair of vertices there exists a path not containing a. This path would remain even after removal of a and thus the graph would remain connected. If the graph were not biconnected, so that there exist three distinct vertices v, w and a such that all paths from v to w passed through a, then the removal of a would have split the graph into atleast two connected components. The vertex a in this case would have been called an articulation vertex. We can say that a graph is biconnected if and only if it has no articulation points. Just like we defined the connected components of a graph we can similarly define the biconnected components of a graph. First, we define a relation R on the edges of a graph. Under R, edges e and f are related if 1-4 Lecture 1: July 24 either e = f of there exists a cycle that contains both e and f. That the relation is an equivalence relation is easy to see and prove. For each equivalence class Ei of this relation, we can also prove that the subgraph induced by it is biconnected. A subgraph of a graph G is said to be induced by a set E of edges if it's vertex set contains exactly those vertices of G that are incident on atleast one edge in E, and its edge set is the set E. Theorem 1.2 Each equivalence class of R induces a biconnected subgraph of G. Proof: Consider any triple v, w and a of vertices in G. Assume for the sake of contradiction that a is an articulation vertex and that all paths from v to w pass through a. Consider any such path. It would have exactly two edges that are incident on a (one `coming into' and the other `going out'). Since these are in the same biconnected component, there has to be a cycle containing these two edges (due to R). If we travel the other way round this cycle we can clearly `bypass' a and therefore create a path from v to w that does not have a.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages6 Page
-
File Size-