Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/tsort.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def self.each_strongly_connected_component(each_node, each_child) # :yields: nod
# #=> [4]
# # [2, 3]
#
def each_strongly_connected_component_from(node, id_map={}, stack=[], &block) # :yields: nodes
def each_strongly_connected_component_from(node, id_map=nil, stack=nil, &block) # :yields: nodes
TSort.each_strongly_connected_component_from(node, method(:tsort_each_child), id_map, stack, &block)
end

Expand All @@ -410,9 +410,12 @@ def each_strongly_connected_component_from(node, id_map={}, stack=[], &block) #
# # [2, 3]
# # [1]
#
def self.each_strongly_connected_component_from(node, each_child, id_map={}, stack=[]) # :yields: nodes
def self.each_strongly_connected_component_from(node, each_child, id_map=nil, stack=nil) # :yields: nodes
return to_enum(__method__, node, each_child, id_map, stack) unless block_given?

id_map ||= {}
stack ||= []

minimum_id = node_id = id_map[node] = id_map.size
stack_length = stack.length
stack << node
Expand Down