# File lib/rgl/traversal.rb, line 100 100: def attach_distance_map (map = Hash.new(0)) 101: @dist_map = map 102: 103: class << self 104: 105: def handle_tree_edge (u, v) 106: super 107: @dist_map[v] = @dist_map[u] + 1 108: end 109: 110: # Answer the distance to the start vertex. 111: 112: def distance_to_root (v) 113: @dist_map[v] 114: end 115: 116: end # class 117: end