Class: Dijkstra::Path

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

Overview

The resulting shortest path will be an object of the Path class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, destination) ⇒ Path

Distance variable stores the total distance of the path Path array has the vertices connecting the shortest path Starting point, ending point are used to get the source and destination of the resulting path if needed



10
11
12
13
14
15
# File 'lib/dijkstra_trace.rb', line 10

def initialize(source, destination)
    @starting_point = source
    @ending_point = destination
    @distance = 0
    @path = []
end

Instance Attribute Details

#distanceObject

Returns the value of attribute distance.



5
6
7
# File 'lib/dijkstra_trace.rb', line 5

def distance
  @distance
end

#ending_pointObject

Returns the value of attribute ending_point.



5
6
7
# File 'lib/dijkstra_trace.rb', line 5

def ending_point
  @ending_point
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/dijkstra_trace.rb', line 5

def path
  @path
end

#starting_pointObject

Returns the value of attribute starting_point.



5
6
7
# File 'lib/dijkstra_trace.rb', line 5

def starting_point
  @starting_point
end