Class: CSVPlusPlus::Graph::DependencyGraph

Inherits:
Hash
  • Object
show all
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

Instance Method Summary collapse

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