Module: Utils::CycleTolerantTSort Private
- Extended by:
- T::Helpers
- Included in:
- Homebrew::Bundle::Brew::Topo, TopologicalHash
- Defined in:
- utils/topological_hash.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Cycle-tolerant ordering for graphs that include TSort.
Instance Method Summary collapse
-
#tsort_with_cycles(&on_cycle) {|cycles| ... } ⇒ Array<T.untyped>
private
Orders nodes dependency-first like tsort but, unlike tsort, does not raise on a cycle: yields cyclic components (size > 1) to the block and returns the flattened component order.
Instance Method Details
#tsort_with_cycles(&on_cycle) {|cycles| ... } ⇒ Array<T.untyped>
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Orders nodes dependency-first like tsort but, unlike tsort, does not raise on a cycle: yields cyclic components (size > 1) to the block and returns the flattened component order.
20 21 22 23 24 25 |
# File 'utils/topological_hash.rb', line 20 def tsort_with_cycles(&on_cycle) components = each_strongly_connected_component.to_a cycles = components.select { |component| component.size > 1 } yield(cycles) if cycles.any? components.flatten end |