monora/rgl

Remove superfluous :GRAY assignment in depth first visit

monora opened this issue · 0 comments

Discussed in #65

Originally posted by delphaber October 12, 2022
Isn't line 200 superfluous? We are already marking the vertex as :GRAY in line 192 when we go deeper in the recursion level at line 201.

Just wondering if I'm missing something :)

rgl/lib/rgl/traversal.rb

Lines 191 to 201 in 3cdf5c2

def depth_first_visit(u, vis = DFSVisitor.new(self), &b)
vis.color_map[u] = :GRAY
vis.handle_examine_vertex(u)
each_adjacent(u) do |v|
vis.handle_examine_edge(u, v)
if vis.follow_edge?(u, v) # (u,v) is a tree edge
vis.handle_tree_edge(u, v) # also discovers v
vis.color_map[v] = :GRAY # color of v was :WHITE
depth_first_visit(v, vis, &b)