class ArchSpec::Rules::StronglyConnectedComponents
Tarjanβs algorithm: the components that mutually reach each other, in one pass over the graph.
Public Class Methods
Source
# File lib/archspec/rules/cycle_rule.rb, line 129 def initialize(adjacency) @adjacency = adjacency @index = 0 @indexes = {} @lowlinks = {} @stack = [] @on_stack = Set.new @found = [] end
Source
# File lib/archspec/rules/cycle_rule.rb, line 125 def self.of(adjacency) new(adjacency).components end
Public Instance Methods
Source
# File lib/archspec/rules/cycle_rule.rb, line 139 def components @adjacency.each_key { |node| visit(node) unless @indexes.key?(node) } @found end