articulation points, bridges, bi-connectivity

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

Upload: nico

Post on 24-Feb-2016

39 views

Category:

Documents


0 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Articulation  Points,  Bridges,  Bi-connectivity

Articulation Points, Bridges, Bi-

connectivity“Critical nodes, critical edges” and connectivity

Ivaylo Kenov

Telerik Corporationhttp:/telerikacademy.

com

Telerik Academy Student

Page 2: Articulation  Points,  Bridges,  Bi-connectivity

Table of Contents

1. Connectivity2. Articulation points3. Bridges4. Bi-connectivity

K-connectivity5. Algorithm6. Additional information

2

Page 3: Articulation  Points,  Bridges,  Bi-connectivity

ConnectivityConnecting the chain

Page 4: Articulation  Points,  Bridges,  Bi-connectivity

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

Page 5: Articulation  Points,  Bridges,  Bi-connectivity

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!

5

Page 6: Articulation  Points,  Bridges,  Bi-connectivity

Connectivity (3)

6

foreach node from graph G{ if node is unvisited

{ DFS(node); counterOfComponents++;}

}

Algorithm:

*Note: Do not forget to mark each node in the DFS as visited!

Page 7: Articulation  Points,  Bridges,  Bi-connectivity

Connectivity (4) Connected graph - 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!

7

Page 8: Articulation  Points,  Bridges,  Bi-connectivity

Articulation pointWhat is it?

Page 9: Articulation  Points,  Bridges,  Bi-connectivity

Articulation point (or node)

Usually used in unordered connected graphs (containing one connected component ).

If removed (with all its edges) divides the graph into 2 or more connected components.

Page 10: Articulation  Points,  Bridges,  Bi-connectivity

Bridge"Articulation edge"

Page 11: Articulation  Points,  Bridges,  Bi-connectivity

Bridge The same as articulation points but this time we remove edges.

If removed divides the graph into 2 or more connected components.

11

Page 12: Articulation  Points,  Bridges,  Bi-connectivity

Bi-connectivityGraph with no articulation points

Page 13: Articulation  Points,  Bridges,  Bi-connectivity

Bi-connectivity (1) An unordered connected 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.

13

Page 14: Articulation  Points,  Bridges,  Bi-connectivity

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-connected graph is a graph in which if we remove any k-1 number of edges, it will remain connected.

14

Page 15: Articulation  Points,  Bridges,  Bi-connectivity

AlgorithmFind articulation points

Page 16: Articulation  Points,  Bridges,  Bi-connectivity

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

16

Page 17: Articulation  Points,  Bridges,  Bi-connectivity

Algorithm (2) A node K is an articulation point if there are two other nodes I and J that each path between I and J goes through K.

This statement does not work for the root of the DFS traversal tree - it has no parent nodes.

17

Page 18: Articulation  Points,  Bridges,  Bi-connectivity

Algorithm (3) So how to check the root? Easy! If it has two or more child elements - it is articulation point!

18

Page 19: Articulation  Points,  Bridges,  Bi-connectivity

Algorithm (4) We use two arrays:

Prenumerator[] - we number the nodes in the graph with DFS instead 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

19

Page 20: Articulation  Points,  Bridges,  Bi-connectivity

Algorithm (5)

20

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); } }

The altered DFS to numerate nodes:

Page 21: Articulation  Points,  Bridges,  Bi-connectivity

Algorithm (6)

21

/* traversing the tree in postorder */ 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]); }

DFS tree traversal with post-order:

Page 22: Articulation  Points,  Bridges,  Bi-connectivity

Algorithm (7)

22

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…

Articulation points algorithm:

Page 23: Articulation  Points,  Bridges,  Bi-connectivity

Algorithm (8)

23

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[];}

Articulation points algorithm:

*Note: If you have a graph with huge number of nodes, you should use Stack instead of recursion in the algorithm!

Page 24: Articulation  Points,  Bridges,  Bi-connectivity

AlgorithmLive demo

Page 26: Articulation  Points,  Bridges,  Bi-connectivity

форум програмиране, форум уеб дизайнкурсове и уроци по програмиране, уеб дизайн – безплатно

програмиране за деца – безплатни курсове и уроцибезплатен SEO курс - оптимизация за търсачки

уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop

уроци по програмиране и уеб дизайн за ученициASP.NET MVC курс – HTML, SQL, C#, .NET, ASP.NET MVC

безплатен курс "Разработка на софтуер в cloud среда"

BG Coder - онлайн състезателна система - online judge

курсове и уроци по програмиране, книги – безплатно от Наков

безплатен курс "Качествен програмен код"

алго академия – състезателно програмиране, състезанияASP.NET курс - уеб програмиране, бази данни, C#, .NET, ASP.NET

курсове и уроци по програмиране – Телерик академия

курс мобилни приложения с iPhone, Android, WP7, PhoneGapfree C# book, безплатна книга C#, книга Java, книга C# Дончо Минков - сайт за програмиране

Николай Костов - блог за програмиранеC# курс, програмиране, безплатно

?? ? ?

??? ?

?

? ?

??

?

?

? ?

Questions?

?http://algoacademy.telerik.com

Page 27: Articulation  Points,  Bridges,  Bi-connectivity

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