diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-17 03:32:15 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-17 03:32:15 +0000 |
commit | ed6231195b8c516a32019e1967366af7793e8313 (patch) | |
tree | e0fdc604d941d1bf5fa54c7b8a4184b7b2dc22f0 /test/test_tsort.rb | |
parent | 209376034f9a26fa3e9eb56516dbc5ade6b85e47 (diff) | |
download | ruby-ed6231195b8c516a32019e1967366af7793e8313.tar.gz |
* lib/tsort.rb (TSort.each_strongly_connected_component_from):
Extracted from TSort#each_strongly_connected_component_from.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_tsort.rb')
-rw-r--r-- | test/test_tsort.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/test_tsort.rb b/test/test_tsort.rb index 38018c49c0..a732064f31 100644 --- a/test/test_tsort.rb +++ b/test/test_tsort.rb @@ -40,5 +40,15 @@ class TSortTest < Test::Unit::TestCase # :nodoc: assert_equal([[0], [1]], a.strongly_connected_components.map {|nodes| nodes.sort}) end + + def test_noclass + g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} + each_child = lambda {|n, &b| g[n].each(&b) } + r = [] + TSort.each_strongly_connected_component_from(1, each_child) {|scc| + r << scc + } + assert_equal([[4], [2, 3], [1]], r) + end end |