module Bundler::TSort

def tsort_each(&block) # :yields: node

:yields: node

# 1
# 3
# 2
#=> 4
graph.tsort_each {|n| p n }
graph = G.new({1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]})

end
def tsort_each_node(&b) @g.each_key(&b) end
def tsort_each_child(n, &b) @g[n].each(&b) end
end
@g = g
def initialize(g)
include Bundler::TSort
class G

If there is a cycle, Bundler::TSort::Cyclic is raised.
#tsort_each returns +nil+.

modification of _obj_ during the iteration may lead to unexpected results.
obj.tsort_each is similar to obj.tsort.each, but
The iterator version of the #tsort method.
def tsort_each(&block) # :yields: node
  each_node = method(:tsort_each_node)
  each_child = method(:tsort_each_child)
  Bundler::TSort.tsort_each(each_node, each_child, &block)
end