method
each_strongly_connected_component_from
Ruby latest stable (v2_5_5)
-
0 notes -
Class: TSort
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
each_strongly_connected_component_from(node, each_child, id_map={}, stack=[])
public
Iterates over strongly connected components in a graph. The graph is represented by node and each_child.
node is the first node. each_child should have call method which takes a node argument and yields for each child node.
Return value is unspecified.
#TSort.each_strongly_connected_component_from is a class method and it doesn’t need a class to represent a graph which includes TSort.
graph = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} each_child = lambda {|n, &b| graph[n].each(&b) } TSort.each_strongly_connected_component_from(1, each_child) {|scc| p scc } #=> [4] # [2, 3] # [1]