Class: Dijkstraruby::Vertex
- Inherits:
-
Object
- Object
- Dijkstraruby::Vertex
- Defined in:
- lib/dijkstraruby/vertex.rb
Instance Attribute Summary collapse
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#name ⇒ Object
Returns the value of attribute name.
-
#neighbours ⇒ Object
Returns the value of attribute neighbours.
-
#prev_vertice ⇒ Object
Returns the value of attribute prev_vertice.
Instance Method Summary collapse
- #change_distance_and_previous(distance, previous_vertice) ⇒ Object
-
#initialize(name, neighbours, distance, prev = nil) ⇒ Vertex
constructor
A new instance of Vertex.
- #set_zero_for_initial_vertice ⇒ Object
Constructor Details
#initialize(name, neighbours, distance, prev = nil) ⇒ Vertex
Returns a new instance of Vertex.
8 9 10 11 12 13 |
# File 'lib/dijkstraruby/vertex.rb', line 8 def initialize(name, neighbours, distance, prev = nil) @name = name @neighbours = neighbours @distance = distance @prev_vertice = prev end |
Instance Attribute Details
#distance ⇒ Object
Returns the value of attribute distance.
6 7 8 |
# File 'lib/dijkstraruby/vertex.rb', line 6 def distance @distance end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/dijkstraruby/vertex.rb', line 6 def name @name end |
#neighbours ⇒ Object
Returns the value of attribute neighbours.
6 7 8 |
# File 'lib/dijkstraruby/vertex.rb', line 6 def neighbours @neighbours end |
#prev_vertice ⇒ Object
Returns the value of attribute prev_vertice.
6 7 8 |
# File 'lib/dijkstraruby/vertex.rb', line 6 def prev_vertice @prev_vertice end |
Instance Method Details
#change_distance_and_previous(distance, previous_vertice) ⇒ Object
19 20 21 22 |
# File 'lib/dijkstraruby/vertex.rb', line 19 def change_distance_and_previous(distance, previous_vertice) @distance = distance @prev_vertice = previous_vertice.name end |
#set_zero_for_initial_vertice ⇒ Object
15 16 17 |
# File 'lib/dijkstraruby/vertex.rb', line 15 def set_zero_for_initial_vertice @distance = 0 end |