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

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
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,
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.
Tree A connected graph that contains no simple circuits is called a tree. Because a tree cannot have a simple circuit, a tree cannot contain multiple.
1 Introduction to trees Instructor: Dimitrios Kosmopoulos.
1 Applications of BFS and DFS CSE 2011 Winter May 2016.
Graphs.
CMSC 341 B- Trees D. Frey with apologies to Tom Anastasio.
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.
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 Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
7 Finding Bridge in a Graph. What is a bridge ? A C D B F G E.
Data Structures and Algorithm Analysis Graph Algorithms Lecturer: Jing Liu Homepage:
5. Biconnected Components of A Graph If one city’s airport is closed by bad weather, can you still fly between any other pair of cities? If one computer.
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
Articulation Points 1 of 2 (Ideas)
Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008
Discrete Mathematicsq
Csc 2720 Instructor: Zhuojun Duan
Discrete Math 2 Weighted Graph Search Tree
Lecture 12 Graph Algorithms
Eager Prim Dijkstra.
Data Structures and Database Applications Binary Trees in C#
Common final examinations
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
Breadth-First Search (BFS)
Biconnected Graph Articulation Points
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
Trees CMSC 202, Version 5/02.
Chapter 11 Graphs.
2017, Fall Pusan National University Ki-Joune Li
CMSC 202 Trees.
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.
Depth-First Search CSE 2011 Winter April 2019.
Bridges and Articulation Points
Applications of DFS: Articulation Points and Biconnected Components
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Biconnectivity SEA PVD ORD FCO SNA MIA 5/23/ :21 PM
Assignment 03 Algorithms & Examples.
Lecture 11 Graph Algorithms
Chapter 9: Graphs Spanning 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); } 1-based counting 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 already 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 E.g. (B, D) 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 Def: Low[] records the earliest ancestor a node and its children could reach 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] fix v, for all w 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 the 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 could reach A What if children of B could have smaller low value? When we search from node v, we DO NOT know low[w] until we return from the next recursive call 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 w

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 could finally decide that 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 Special case for root node

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 (1, 1) A L F M J B H D C K G I E (2, 2) A L M J B H K G I D E C F pre 1 2 3 4 low (3, 3) (3, 2) (5, 5) A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 low (4, 2) (6, 6) (6, 5) A L M J B H K G I D E C F pre 1 2 3 4 5 6 7 8 9 low (10, 10) (7, 7) (11, 5) (7, 5) (8, 5) 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 (9, 9)

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 (1, 1) A L F M J B H D C K G I E (13, 13) (2, 2) (2, 1) 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 (3, 3) (3, 2) (3, 1) (5, 5) 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 (4, 2) (5, 1) (12, 1) (6, 6) (6, 5) 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 (10, 10) (7, 7) (10, 5) (11, 5) (7, 5) (8, 5) 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 (9, 9)