# File lib/puppet/simple_graph.rb, line 360
360:   def walk(source, direction)
361:     # Use an iterative, breadth-first traversal of the graph. One could do
362:     # this recursively, but Ruby's slow function calls and even slower
363:     # recursion make the shorter, recursive algorithm cost-prohibitive.
364:     stack = [source]
365:     seen = Set.new
366:     until stack.empty?
367:       node = stack.shift
368:       next if seen.member? node
369:       connected = adjacent(node, :direction => direction)
370:       connected.each do |target|
371:         yield node, target
372:       end
373:       stack.concat(connected)
374:       seen << node
375:     end
376:   end