def attach_distance_map (map = Hash.new(0))
      @dist_map = map

      class << self

        def handle_tree_edge (u, v)
          super
          @dist_map[v] = @dist_map[u] + 1
        end

        # Answer the distance to the start vertex.

        def distance_to_root (v)
          @dist_map[v]
        end

      end	# class
    end
def attach_distance_map (map = Hash.new(0))
      @dist_map = map

      class << self

        def handle_tree_edge (u, v)
          super
          @dist_map[v] = @dist_map[u] + 1
        end

        # Answer the distance to the start vertex.

        def distance_to_root (v)
          @dist_map[v]
        end

      end	# class
    end
Attach a map to the visitor which records the distance of a visited
 vertex to the start vertex.

 This is similar to BGLs
 distance_recorder[http://www.boost.org/libs/graph/doc/distance_recorder.html].

 After the distance_map is attached, the visitor has a new method
 distance_to_root, which answers the distance to the start vertex.