docs: def label_components(self, display = None):
          '''
          API: label_components(self, display=None)
          Description:
          This method labels the nodes of an undirected graph with component
          numbers so that each node has the same label as all nodes in the
          same component. It will display the algortihm if display argument is
          provided.
          Input:
              display: display method.
          Pre:
              self.graph_type should be UNDIRECTED_GRAPH.
          Post:
              Nodes will have 'component' attribute that will have component
              number as value.
          '''
          if self.graph_type == DIRECTED_GRAPH:
              raise Exception("label_components only works for ",
                              "undirected graphs")
          self.num_components = 0
          for n in self.get_node_list():
              self.get_node(n).set_attr('component', None)
          for n in self.neighbors:
              self.get_node(n).set_attr('label', '-')
          for n in self.get_node_list():
              if self.get_node(n).get_attr('component') == None:
                  self.search(n, display=display,
                              component=self.num_components, algo='DFS')
                  self.num_components += 1