1 / 27

Articulation Points, Bridges, Bi-connectivity

Articulation Points, Bridges, Bi-connectivity. “Critical nodes, critical edges” and connectivity. Ivaylo Kenov. Telerik Corporation. http:/telerikacademy.com. Telerik Academy Student. Table of Contents. Connectivity Articulation points Bridges Bi-connectivity K-connectivity

nico
Télécharger la présentation

Articulation Points, Bridges, Bi-connectivity

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Articulation Points, Bridges, Bi-connectivity “Critical nodes, critical edges” and connectivity IvayloKenov Telerik Corporation http:/telerikacademy.com Telerik Academy Student

  2. Table of Contents • Connectivity • Articulation points • Bridges • Bi-connectivity • K-connectivity • Algorithm • Additional information

  3. Connectivity Connecting the chain

  4. Connectivity (1) • Connected component of undirected graph – a subgraph in which any two nodes are connected to each other by paths.

  5. Connectivity (2) • A simple way to find number of connected components - loop through all nodes and start a DFS or BFS traversing from any unvisited node. • Each time you start a new traversing - you find a new connected component!

  6. Connectivity (3) • Algorithm: foreach node from graph G { if node is unvisited { DFS(node); counterOfComponents++; } } *Note: Do not forget to mark each node in the DFS as visited!

  7. Connectivity (4) • Connectedgraph- basically a graph with one connected component • In every connected graph a path exists between any two nodes • Easy algorithm for checking whether a graph is connected - if the previous code return one connected component - graph is connected!

  8. Articulation point What is it?

  9. Articulation point (or node) Usually used in unorderedconnectedgraphs(containing one connected component ). If removed (with all its edges) divides the graph into 2ormoreconnected components.

  10. Bridge "Articulation edge"

  11. Bridge • The same as articulation points but this time we remove edges. • If removed divides the graph into 2ormoreconnected components.

  12. Bi-connectivity Graph with no articulation points

  13. Bi-connectivity (1) • An unorderedconnected graph is called bi-connected when if we remove 1 of its nodes (no matter which one), the graph will remain connected (with 1 connected component). • Has no articulation points.

  14. Bi-connectivity (2) • k-vertex-connected graph is a graph in which if we remove any k-1 number of nodes, it will remain connected.w • k-edge-connectedgraph is a graph in which if we remove any k-1 number of edges, it will remain connected.

  15. Algorithm Find articulation points

  16. Algorithm (1) • One easy (butnotefficient) way to determine articulation point (and bi-connectivity) is to remove node by node from the graph and check whether it is still connected.

  17. Algorithm (2) • A node Kis an articulation point if there are two other nodes Iand Jthat each path between Iand Jgoes through K. • This statement doesnotworkfor the root of the DFS traversal tree - it has no parent nodes.

  18. Algorithm (3) • So how to check the root? • Easy! If it has twoormorechild elements - it is articulation point!

  19. Algorithm (4) • We use two arrays: • Prenumerator[] - we number the nodes in the graph with DFSinstead of just mark them as visited • Lowest[] - the least numbered node that can be obtained by a back edge to one of its ancestors or the least node that can be obtained by a back edge from any one of its descendants. • The check - if the DFS number of the node is <= to the Lowest of any of its children

  20. Algorithm (5) • The altered DFS to numerate nodes: function DFS(i) { prenumerator[i] = ++DFScounter; for (j = 0; j < numberOfNodes; j++) if (A[i][j] != 0 && prenum[j] == 0) { A[i][j] = 2; /* building DFS tree of the graph*/ DFS(j); } }

  21. Algorithm (6) • DFS tree traversal with post-order: /* traversing the tree inpostorder */ function postOrder(i) { unsigned j; for (j = 0; j < numberOfNodes; j++) if (2 == A[i][j]) postOrder(j); lowest[i] = prenumerator[i]; for (j = 0; j < numberOfNodes; j++) if (1 == A[i][j]) lowest[i] = min(lowest[i], prenumerator[j]); for (j = 0; j < numberOfNodes; j++) if (2 == A[i][j]) lowest[i] = min(lowest[i], lowest[j]); }

  22. Algorithm (7) • Articulation points algorithm: function findArticPoints() { articulationPoints[], count; for (i = 0; i < numberOfNodes; i++) { prenum[i] = 0; lowest[i] = 0; artPoints[i] = 0; } DFScounter= 0; DFS(0); for (i = 0; i < numberOfNodes; i++) if (0 == prenumerator[i]) { “Graph is not connected!"; return; } postOrder(0); count = 0; for (i = 0; i < numberOfNodes; i++) //checking root if (2 == A[0][i]) count++; if (count > 1) artPoints[0] = 1; Continues…

  23. Algorithm (8) • Articulation points algorithm: Continues… /* checking the rest of the nodes*/ for (i = 1; i < numberOfNodes; i++) { for (j = 0; j < numberOfNodes; j++) if (2 == A[i][j] && lowest[j] >= prenum[i]) break; if (j < n) artPoints[i] = 1; } Print the result from arcPoints[]; } *Note: If you have a graph with huge number of nodes, you should use Stackinstead of recursion in the algorithm!

  24. Algorithm Live demo

  25. Additional information • Bi-connectivity: http://www.seas.gwu.edu/~ayoussef/cs212/graphsearch.html#biconnectivity • Algorithm for articulation points: http://nbangla.blogspot.com/2012/12/cpp-articulation-points-detection-algorithm.html • Algorithm for bridges: http://www.aspfree.com/c/a/code-examples/articulation-edges-and-vertexes/ • “Programming = ++Algorithms” by P. Nakov;

  26. http://algoacademy.telerik.com

  27. Free Trainings @ Telerik Academy • “C# Programming @ Telerik Academy • csharpfundamentals.telerik.com • Telerik Software Academy • academy.telerik.com • Telerik Academy @ Facebook • facebook.com/TelerikAcademy • Telerik Software Academy Forums • forums.academy.telerik.com

More Related