Class: Silicium::Graphs::TopologicalSortClass

Inherits:
Object
  • Object
show all
Defined in:
lib/topological_sort.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph) ⇒ TopologicalSortClass

Returns a new instance of TopologicalSortClass.



34
35
36
37
38
39
# File 'lib/topological_sort.rb', line 34

def initialize(graph)
  @post_order = []
  @visited = []

  graph.nodes.each { |node| dfs(node) unless @visited.include?(node)}
end

Instance Attribute Details

#post_orderObject

Returns the value of attribute post_order.



32
33
34
# File 'lib/topological_sort.rb', line 32

def post_order
  @post_order
end