6.1 Connected Components of a Graph

If C G V G C(G)\subset V(G) , a similar procedure (Algorithm 9) extracts a set of components from G G whose roots are defined by C G C(G) . It assumes that C G C(G) and V G V(G) are maintained in simple lists (Section 3.3 examines the list data type).

Algorithm 9: Extract the Connected Components of a Graph
k = k= first( V V )
while  k e o l k\neq eol
   map( γ , v , u n v i s i t e d \gamma,v,unvisited )
    k = k= next( V , k V,k )
d f n = 0 dfn=0
k = k= first( C C )
while  k e o l k\neq eol
   if evaluate( γ , v \gamma,v ) is u n v i s i t e d unvisited
       d e p t h = 0 depth=0
      dfs( v v )
    k = k= next( C , k C,k )