The iterator version of the #tsort method. obj.tsort_each is similar to obj.tsort.each, but modification of obj during the iteration may lead to unexpected results.
#tsort_each returns nil. If there is a cycle, TSort::Cyclic is raised.
Source Code
# File tsort.rb, line 148 def tsort_each # :yields: node each_strongly_connected_component {|component| if component.size == 1 yield component.first else raise Cyclic.new("topological sort failed: #{component.inspect}") end } end
<code/>and<pre/>for code samples.