+ All Categories
Home > Documents > Graph (III)

Graph (III)

Date post: 26-Jan-2016
Category:
Upload: nituna
View: 27 times
Download: 2 times
Share this document with a friend
Description:
Graph (III). Trees, Articulation point, Bridge, SCC. GGuy 19-3-2011. Review. Shortest path Dijkstra Bellman Ford Floyd Warshall Minimum Spanning Tree Prim’s Kruskal’s. Tree. The following four conditions are equivalent: G is connected and acyclic - PowerPoint PPT Presentation
29
Graph (III) Trees, Articulation point, Bridge, SCC GGuy 19-3-2011
Transcript
Page 1: Graph (III)

Graph (III)

Trees, Articulation point, Bridge, SCC

GGuy19-3-2011

Page 2: Graph (III)

Review

Shortest pathDijkstraBellman FordFloyd Warshall

Minimum Spanning TreePrim’sKruskal’s

Page 3: Graph (III)

Tree

• The following four conditions are equivalent:– G is connected and acyclic– G is connected and |E| = |V| - 1 – G is acyclic and |E| = |V| - 1– Between any pair of vertices in G, there exists a

unique path• G is a tree if at least one of the above

conditions is satisfied

Page 4: Graph (III)

Tree

• |E| = |V| - 1• Between any pair of vertices, there is a unique path• Adding an edge between a pair of non-adjacent

vertices creates exactly one cycle• Removing an edge from the tree breaks the tree into

two smaller trees

Page 5: Graph (III)

Tree

root

siblings

descendants children

ancestors

parent

Page 6: Graph (III)

Tree Diameter

Find the farthest node from root, say it uFind the farthest node from u, say it v

(u, v) = Tree diameter

Page 7: Graph (III)

DFS TreeDFS (vertex u) {mark u as visited

time = time + 1birth[u] = time;for each vertex v directly reachable from u

if v is unvisitedparent[v] = uDFS (v)

time = time + 1death[u] = time;

}

Page 8: Graph (III)

A

F

B

C

D

E

GH

DFS forest (Demonstration)A B C D E F G H

birth

death

parent

unvisited

visited

visited (dead)

A

B

C

F

E

D

G

1 2 3 13 10 4 14

12 9 8 16 11 5 15

H

6

7

- A B - A C D C

Page 9: Graph (III)

Classification of edges

• Tree edge• Forward edge• Back edge• Cross edge

• Question: which type of edges is always absent in an undirected graph?

A

B

C

F

E

D

G

H

Page 10: Graph (III)

Determination of edge types

• How to determine the type of an arbitrary edge (u, v) after DFS?

• Tree edge– parent [v] = u

• Forward edge– not a tree edge; and– birth [v] > birth [u]; and– death [v] < death [u]

• How about back edge and cross edge?

Page 11: Graph (III)

Determination of edge types

Tree edge Forward Edge Back Edge Cross Edge

parent [v] = u

not a tree edgebirth[v] > birth[u]death[v] < death[u]

birth[v] < birth[u]death[v] > death[u]

birth[v] < birth[u]death[v] < death[u]

Page 12: Graph (III)

Articulation Point

For a undirected graph G,Node u is an Articulation Point if remove u from G will create more components.

Page 13: Graph (III)

Articulation Point

Page 14: Graph (III)

Bridge

For a undirected graph G,Edge (u, v) is an bridge if remove (u, v) from G will create more components.

Page 15: Graph (III)

Bridge

Page 16: Graph (III)

Finding AP and Bridge

DFS(vertex u)time = time + 1low[u] = vis[u] = timefor each vertex v directly reachable from u

if v is not visitedDFS(v)low[u] = min(low[u], low[v])

if v is visited and parent of u is not v

low[u] = min(low[u], vis[v])

Page 17: Graph (III)

Finding AP

Find the DFS tree of G and compute low[]

Vertex u is an AP if

1. u is the root and u has >1 children2. u is not the root and there exists children v where low[v] >= vis[u]

Page 18: Graph (III)

Finding Bridge

Find the DFS tree of G and compute low[]

Edge (u, v) is a Bridge if

1. v is u children and low[v] > vis[u]

Page 19: Graph (III)

Bi-connected component

A bi-connected component (or 2-connected component) is a maximal bi-connected subgraph

A bi-connected subgraph is a graph that has no articulation point

Page 20: Graph (III)

Bi-connected component

Each Bi-connected component isconnected by bridge

Each articulation point belongs to morethan one Bi-connected component

The Bi-connected components form a Tree

Page 21: Graph (III)

Bi-connected component

Page 22: Graph (III)

Strongly Connected Component

In a directed graph G, a Strongly Connected Component is a subgraph that there is a path from each vertex to every other vertex in the same SCC.

Page 23: Graph (III)

Strongly Connected Component

Page 24: Graph (III)

Finding SCC

• Compute the DFS forest of the graph G to get the death time of the vertices

• Reverse all edges in G to form G’• Compute a DFS forest of G’, but always choose

the vertex with the latest death time when choosing the root for a new tree

• The SCCs of G are the DFS trees in the DFS forest of G’

Page 25: Graph (III)

A

F

B

C

D

GH

SCC (Demonstration)

A

F

B

C

D

E

GH

A B C D E F G H

birth

death

parent

1 2 3 13 10 4 14

12 9 8 16 11 5 15

6

7

- A B - A C D C

D

G

A E B

F

C

H

Page 26: Graph (III)

SCC (Demonstration)

D

G

A E B

F

C

H

A

F

B

C

D

GH

E

Page 27: Graph (III)

Finding SCC

Assume (u, v) belongs to the same SCCWLOG, assume u is visited first. Since the exists a path from u to v, we havedeath[u] > death[v]

When we do DFS on G’, we will call DFS(u) first. Since there exists a path from v to u in G, then there exists path from u to v in G’, hence v and u will be in the same tree.

Page 28: Graph (III)

Iterative Depth Searching (IDS)

Page 29: Graph (III)

Bi – Directional Searching (BDS)


Recommended