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