Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
COMP261 Lecture 8 Articulation Points 1 of 2 (Ideas) Outline • What/Why articulation point • Find articulation points (bad algorithm) • Find articulation points (a better idea) Connectedness • Is this graph connected or not? D BB C A FF U W T E N I V S AA H Z R M K B X F L G Y CC J DD P GG Q EE O Articulation points • This graph is connected, but is it “fragile”? Would deleting one node disconnect it? D C A BB T FF U W E V I N H B AA K F Z M X G R Y L CC J P GG Q EE O DD • Articulation point: node whose removal would disconnect part of the graph. Applications • • • • Wireless sensor networks Road networks Social networks Military Articulation Points: a bad algorithm • Take each node out in turn, and test for connectedness articulationPoints ← empty set for each node in graph node.visited ← true; for all other nodes nd: nd.visited ← false recDFS(first neighbour of node) for each remaining neighbour of node if not neighbour.visited then add node to articulationPoints recDFS(node): if not node.visited then node.visited ← true, for each neighbour of node if not neighbour.visited then recDFS(neighbour ) Why is it bad? • Cost of DFS: – O(e) = O(n2) for very dense graphs • Cost of Alg: – O(ne) = O(n3) for very dense graphs • Why do we have to traverse the whole graph n times, once for each node? • Why not do a single traversal, identifying all articulation points as we go? Articulation Points • What are we looking for? Group 1 M P Nodes in a graph that separate the graph into two groups, so that all paths from nodes in one group to nodes in the other group go through the node. R S U Group 2 N T Q W Articulation Points: DFS • Traverse the graph using DFS, keep track of the count number of each node in the search tree B A 1 In the graph but not in the search tree A B 2 C 3 C D G D F E 5 E F 6 4 G 7 Articulation Points: DFS • In the search tree, each node separates all the nodes into two subsets – The subtree nodes – The non-subtree nodes • Check if each subtree node is connected to the non-subtree nodes if the node breaks down (whether there are alternative paths) A 1 B 2 – Do we need to check {D,E,F} and {G}? – No C 3 • Alternative path from {D,E,F} to {A,B} • Alternative path from {G} to {A,B} • ⇒ Alternative path from {D,E,F} to {G} F D E 5 6 4 G 7 Articulation Points: DFS • A node is an articulation point if there exists a subtree node that is connected to non-subtree nodes only through the node, i.e. there is not alternative path • An alternative path uses the edges that are in the graph but not in the search tree (back edges) • How to check that the back edge connects to nonsubtree node? – The other end-node has a smaller count number – All the nodes with smaller count numbers are non-subtree nodes Articulation Points: DFS • C (count = 3) is an articulation point, because there is not back edge from G to A (count = 1) or B (count = 2) • B (count = 2) is not an articulation point, because all the subtree nodes {C, D, E, F, G} can connect via a back edge (D,A) to A (count = 1) A 1 B 2 • D? E? C 3 D • Is it all? • We haven’t checked the root E 5 F 6 4 G 7 Articulation Points: DFS • DFS with another root D • How to check for D? D 1 – No non-subtree node B A A B C D G F E C G 3 4 5 • Whether there are more than one sub-trees 2 E 6 F 7 Articulation Points • Key ideas of algorithm: – Record count number of nodes as you search – From each recursive search of a subtree, return the minimum count number that the subtree nodes can "reach back" to. – Compare the "reach back" of each subtree to count number of this node, if smaller then there is an alternative path