Class: Librarian::Algorithms::GraphHash
- Inherits:
-
Hash
- Object
- Hash
- Librarian::Algorithms::GraphHash
- Includes:
- TSort
- Defined in:
- lib/librarian/algorithms.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from(hash) ⇒ Object
17 18 19 20 21 |
# File 'lib/librarian/algorithms.rb', line 17 def from(hash) o = new hash.each{|k, v| o[k] = v} o end |
Instance Method Details
#tsort_each_child(node, &block) ⇒ Object
12 13 14 15 |
# File 'lib/librarian/algorithms.rb', line 12 def tsort_each_child(node, &block) children = self[node] children && children.sort.each(&block) # demand determinism end |
#tsort_each_node(&block) ⇒ Object
9 10 11 |
# File 'lib/librarian/algorithms.rb', line 9 def tsort_each_node(&block) keys.sort.each(&block) # demand determinism end |