Ruby 2.1.0 リファレンスマニュアル > ライブラリ一覧 > tsortライブラリ > TSortモジュール > each_strongly_connected_component
each_strongly_connected_component(each_node, each_child) {|nodes| ...} -> nil
[permalink][rdoc]TSort.strongly_connected_components メソッドのイテレータ版です。
引数 each_node と each_child でグラフを表します。
使用例
g = {1=>[2, 3], 2=>[4], 3=>[2, 4], 4=>[]} each_node = lambda {|&b| g.each_key(&b) } each_child = lambda {|n, &b| g[n].each(&b) } TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc } # => [4] # [2] # [3] # [1] g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} each_node = lambda {|&b| g.each_key(&b) } each_child = lambda {|n, &b| g[n].each(&b) } TSort.each_strongly_connected_component(each_node, each_child) {|scc| p scc } # => [4] # [2, 3] # [1]
[SEE_ALSO] TSort#each_strongly_connected_component