Class: CSVPlusPlus::Graph::DependencyGraph
- Inherits:
-
Hash
- Object
- Hash
- CSVPlusPlus::Graph::DependencyGraph
- Includes:
- TSort
- Defined in:
- lib/csv_plus_plus/graph.rb
Overview
A dependency graph represented as a Hash
which will be used by our topological_sort
function
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
create a
DependencyGraph
from aHash
.
Instance Method Summary collapse
-
#tsort_each_child(node) ⇒ Object
sort each child.
Class Method Details
.from_hash(hash) ⇒ Object
create a DependencyGraph
from a Hash
58 59 60 |
# File 'lib/csv_plus_plus/graph.rb', line 58 def self.from_hash(hash) self[hash.map { |k, v| [k, v] }] end |
Instance Method Details
#tsort_each_child(node) ⇒ Object
sort each child
63 64 65 |
# File 'lib/csv_plus_plus/graph.rb', line 63 def tsort_each_child(node, &) fetch(node).each(&) end |