[prev] 30 [next]

Connected Components

Problems:
  • how many connected subgraphs are there?
  • are two vertices in the same connected subgraph?
Both of the above can be solved if we can
  • build an array, one element for each vertex V
  • indicating which connected component V is in
Function components(g) above does this for us.