Class: Silicium::Graphs::TopologicalSortClass
- Inherits:
-
Object
- Object
- Silicium::Graphs::TopologicalSortClass
- Defined in:
- lib/topological_sort.rb
Instance Attribute Summary collapse
-
#post_order ⇒ Object
Returns the value of attribute post_order.
Instance Method Summary collapse
-
#initialize(graph) ⇒ TopologicalSortClass
constructor
A new instance of TopologicalSortClass.
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_order ⇒ Object
Returns the value of attribute post_order.
32 33 34 |
# File 'lib/topological_sort.rb', line 32 def post_order @post_order end |