Академический Документы
Профессиональный Документы
Культура Документы
l Directed: e = (x,y)
l WWW is a graph
Directed or undirected?
l DFS algorithm to find which nodes are reachable from an initial node v
l previsit(v) and postvisit(v) are optional updating procedures
l Complexity?
l DFS algorithm to find which nodes are reachable from an initial node v
l previsit(v) and postvisit(v) are optional updating procedures
l Complexity
Each reachable edge er checked exactly once (twice if undirected)
O(|Er| + |V|)
9
Account for all edges Tree edges and Back edges
Previsit and Postvisit Orders
DFS yields a forest (disjoint trees) when there are disjoint components in the graph
Can use pre/post visit numbers to detect properties of graphs
Account for all edges: Tree edges (solid) and back edges (dashed)
Back edges detect cycles
Properties still there even if explored in a different order (i.e. start with F, then J)
l Each time a node is taken from the source list and added to the
A B
e e:5
a
a,1
f pre numbering
g b,2
b
g,3
e
c,4 e,7
c
d
d,5 f,8
h h,6
f low numbering
g b,2,1
b
g,3,1
e
c,4,3 e,7,3
c u is a sep. vertex iff
d
there is any child v of u s.t.
d,5,3 f,8,3
low(v) pre(u)
h h,6,4
f low numbering
g b,2,1
b
g,3,1
e
c,4,3 e,7,1
c u is a sep. vertex iff
d
there is any child v of u s.t.
d,5,3 f,8,1
low(v) pre(u)
h h,6,4
a 3
b
5
c 2
9 d
4
1