def each_connected_component
      raise NotUndirectedError,
        "each_connected_component only works " +
        "for undirected graphs." if directed?
      comp = []
      vis  = DFSVisitor.new(self)
      vis.set_finish_vertex_event_handler { |v| comp << v }
      vis.set_start_vertex_event_handler { |v|
        yield comp unless comp.empty?
        comp = []
      }
      depth_first_search(vis) { |v| }
      yield comp unless comp.empty?
    end
def each_connected_component
      raise NotUndirectedError,
        "each_connected_component only works " +
        "for undirected graphs." if directed?
      comp = []
      vis  = DFSVisitor.new(self)
      vis.set_finish_vertex_event_handler { |v| comp << v }
      vis.set_start_vertex_event_handler { |v|
        yield comp unless comp.empty?
        comp = []
      }
      depth_first_search(vis) { |v| }
      yield comp unless comp.empty?
    end
Compute the connected components of an undirected graph, using a
 DFS (Depth-first search)-based approach.  A _connected component_ of
 an undirected graph is a set of vertices that are all reachable
 from each other.

 The function is implemented as an iterator which calls the client
 with an array of vertices for each component.

 It raises an exception if the graph is directed.