Method: RGL::GraphVisitor#attach_distance_map

Defined in:
lib/rgl/graph_visitor.rb

#attach_distance_map(map = Hash.new(0)) ⇒ Object

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.

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



76
77
78
79
80
81
# File 'lib/rgl/graph_visitor.rb', line 76

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

  # add distance map support to the current visitor instance
  extend(DistanceMapSupport)
end