Class: Dijkstraruby::Vertex

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#distanceObject

Returns the value of attribute distance.



6
7
8
# File 'lib/dijkstraruby/vertex.rb', line 6

def distance
  @distance
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/dijkstraruby/vertex.rb', line 6

def name
  @name
end

#neighboursObject

Returns the value of attribute neighbours.



6
7
8
# File 'lib/dijkstraruby/vertex.rb', line 6

def neighbours
  @neighbours
end

#prev_verticeObject

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_verticeObject



15
16
17
# File 'lib/dijkstraruby/vertex.rb', line 15

def set_zero_for_initial_vertice
  @distance = 0
end