Class: Silicium::Graphs::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Node

Returns a new instance of Node.



20
21
22
23
24
# File 'lib/topological_sort.rb', line 20

def initialize(name)
  # using Set instead of an Array to avoid duplications
  @adjacents = Set.new
  @name = name
end

Instance Attribute Details

#adjacentsObject

Returns the value of attribute adjacents.



18
19
20
# File 'lib/topological_sort.rb', line 18

def adjacents
  @adjacents
end

#nameObject

Returns the value of attribute name.



18
19
20
# File 'lib/topological_sort.rb', line 18

def name
  @name
end

Instance Method Details

#to_sObject



26
27
28
# File 'lib/topological_sort.rb', line 26

def to_s
  @name
end