Biconnected Graph Articulation Points

Slides:



Advertisements
Similar presentations
Graph Algorithms Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 11Feb 07, 2014Carnegie Mellon University.
Advertisements

Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
Analysis of Algorithms Depth First Search. Graph A representation of set of objects Pairs of objects are connected Interconnected objects are called “vertices.
CS 312 – Graph Algorithms1 Graph Algorithms Many problems are naturally represented as graphs – Networks, Maps, Possible paths, Resource Flow, etc. Ch.
Breadth-First and Depth-First Search
CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.
Applications of graph traversals
Applications of DFS: Articulation Points and Biconnected Components
Data Structures & Algorithms Graph Search Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
Binary Trees Terminology A graph G = is a collection of nodes and edges. An edge (v 1,v 2 ) is a pair of vertices that are directly connected. A path,
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
A tree is a simple graph satisfying: if v and w are vertices and there is a path from v to w, it is a unique simple path. a b c a b c.
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
IS 2610: Data Structures Graph April 5, 2004.
Graph Search Computing 2 COMP s1. P ROBLEMS ON G RAPHS What kinds of problems do we want to solve on/via graphs? Is there a simple path from A to.
1 Introduction to trees Instructor: Dimitrios Kosmopoulos.
1 Applications of BFS and DFS CSE 2011 Winter May 2016.
Graphs.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Jan Topological Order and SCC Edge classification Topological order Recognition of strongly connected components.
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
Discrete Mathematics Chapter 5 Trees.
Introduction to Graph Theory Lecture 17: Graph Searching Algorithms.
Data Structures Lakshmish Ramaswamy. Tree Hierarchical data structure Several real-world systems have hierarchical concepts –Physical and biological systems.
Graph Connectivity This discussion concerns connected components of a graph. Previously, we discussed depth-first search (DFS) as a means of determining.
Graphs 2015, Fall Pusan National University Ki-Joune Li.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
8/3/2007CMSC 341 BTrees1 CMSC 341 B- Trees D. Frey with apologies to Tom Anastasio.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Graph Search Applications, Minimum Spanning Tree
Articulation Points 2 of 2 (Algorithm)
CSCE 210 Data Structures and Algorithms
Data Structures 13th Week
Discrete Mathematicsq
Csc 2720 Instructor: Zhuojun Duan
12. Graphs and Trees 2 Summary
Discrete Math 2 Weighted Graph Search Tree
Lecture 12 Graph Algorithms
Eager Prim Dijkstra.
Data Structures and Database Applications Binary Trees in C#
CMSC 341 Lecture 10 B-Trees Based on slides from Dr. Katherine Gibson.
CS120 Graphs.
Graph Algorithms Using Depth First Search
Spanning Trees Longin Jan Latecki Temple University based on slides by
Biconnected Graph Articulation Points
Graph Algorithm.
Breadth-First Search (BFS)
Eager Prim Dijkstra.
B- Trees D. Frey with apologies to Tom Anastasio
Bridges and Articulation Points
B- Trees D. Frey with apologies to Tom Anastasio
2018, Fall Pusan National University Ki-Joune Li
Trees Definitions Implementation Traversals K-ary Trees
Chapter 11 Graphs.
2017, Fall Pusan National University Ki-Joune Li
Subgraphs, Connected Components, Spanning Trees
B- Trees D. Frey with apologies to Tom Anastasio
Depth-First Search D B A C E Depth-First Search Depth-First Search
COMP171 Depth-First Search.
Depth-First Search CSE 2011 Winter April 2019.
Algorithms: Design and Analysis
Depth-First Search CSE 2011 Winter April 2019.
Bridges and Articulation Points
Applications of DFS: Articulation Points and Biconnected Components
Assignment 03 Algorithms & Examples.
Lecture 11 Graph Algorithms
Trees.
Graph Traversals Some applications require visiting every vertex in the graph exactly once. The application may require that vertices be visited in some.
GRAPH TRAVERSAL.
Presentation transcript:

Biconnected Graph Articulation Points

Biconnected Graph A biconnected graph has at least 2 distinct paths (no common edges or vertices) between all vertex pairs Any graph that is not biconnected has one or more articulation points Vertices, that, if removed, will separate the graph Any graph that has no articulation points is biconnected Thus we can determine that a graph is biconnected if we look for, but do not find any articulation points

Finding articulation points DFS pre-order traversal Two arrays

DFS pre-order traversal public Biconnected(Graph G) { pre = new int[G.V()]; for (int v = 0; v < G.V(); v++) pre[v] = -1; if (pre[v] == -1) dfs(G, v); } private void dfs(Graph G, int v) { pre[v] = cnt++; for (int w : G.adj(v)) { if (pre[w] == -1) { dfs(G, w); }

DFS pre-order traversal M J B H D C K G I E L B F A M J D C G K I H E private void dfs(Graph G, int v) { pre[v] = cnt++; for (int w : G.adj(v)) { if (pre[w] == -1) { dfs(G, w); }

DFS pre-order traversal M J B H D C K G I E L B F A M J D C G K I H E private void dfs(Graph G, int v) { pre[v] = cnt++; for (int w : G.adj(v)) { if (pre[w] == -1) { dfs(G, w); } pre: A L M J B H K G I D E C F 1 2 3 4 5 6 7 8 9 10 11 12 13

Finding articulation points M J B H D C K G I E Finding articulation points DFS pre-order traversal Two arrays – pre[] pre-order traversal order pre[M]==3 means M is the 3rd node we visit Node close to root should have smaller traversal order number pre: A L M J B H K G I D E C F 1 2 3 4 5 6 7 8 9 10 11 12 13

Finding articulation points M J B H D C K G I E Finding articulation points Spanning tree edges Back edges private void dfs(Graph G, int v) { pre[v] = cnt++; for (int w : G.adj(v)) { if (pre[w] == -1) { // <v, w> is a spanning tree edge dfs(G, w); } else { // <v, w> is a back edge since we have visited node w }

Finding articulation points M J B H D C K G I E Finding articulation points DFS pre-order traversal Two arrays – low[] Low[] records the earliest ancestor a node and its children could reach For spanning tree edge (v, w), low[w] >= pre[v] means v is a articulation point Since the earliest ancestor of w is v, it could not be earlier than v A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 10 11 12 13 low

Finding articulation points M J B H D C K G I E Low[v] records the earliest ancestor node v and its children could reach Min of three cases 1) Basic case: low[v] = prev[v] Node v could reach itself v

Finding articulation points M J B H D C K G I E Low[v] records the earliest ancestor node v and its children could reach Min of three cases 2) v has back edges (v, w): Compare pre[w] to low[v] E.g. node G choose B among {K, H, B} When we search from node v, we know pre[w] since we already visited the node w could not be parent of v w v A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 10 11 12 13 low

Finding articulation points M J B H D C K G I E Low[v] records the earliest ancestor node v and its children could reach Min of three cases 3) v has spanning tree edges (v, w): Compare low[w] to low[v] E.g. node M choose A since its children B and C could reach A When we search from node v, we DONOT know low[w] since just plan to visit it in the next recursive call w v A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 10 11 12 13 low

Finding articulation points M J B H D C K G I E Min of three cases 1) Basic case: low[v] = prev[v] 2) v has back edges (v, w): compare pre[w] to low[v], e.g. node G 3) v has spanning tree edges (v, w): compare low[w] to low[v], e.g. node M For the case 3), we have to make the comparison after recursive call, since then we have information of low[w] Decide the low[] value of leaf node at the beginning Update low[] in the path E.g. Only when we know low[C]=1, we would update low[B]=1, then low[M]=1, low[L]=1

private void dfs(Graph G, int u, int v) { int children = 0; pre[v] = cnt++; low[v] = pre[v]; for (int w : G.adj(v)) { if (pre[w] == -1) { children++; dfs(G, v, w); low[v] = Math.min(low[v], low[w]); if (low[w] >= pre[v] && u != v) articulation[v] = true; } else if (w != u) low[v] = Math.min(low[v], pre[w]); } if (u == v && children > 1) Case 1: basic public Biconnected(Graph G) { low = new int[G.V()]; pre = new int[G.V()]; articulation = new boolean[G.V()]; for (int v = 0; v < G.V(); v++) low[v] = -1; pre[v] = -1; if (pre[v] == -1) dfs(G, v, v); } Case 3: spanning tree edge The condition Case 2: back edge

A L F M J B H D C K G I E A L M J B H K G I D E C F pre 1 2 3 4 low A 5 6 7 8 9 low A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 low A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 10 11 low

A L F M J B H D C K G I E A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 10 11 low A L F M J B H D C K G I E A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 10 11 low A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 10 11 12 low A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 10 11 12 low A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 10 11 12 13 low