Class: Doodl::FloydWarshall

Inherits:
Object
  • Object
show all
Includes:
AllPairShortestPaths
Defined in:
lib/shortest_path/floyd_warshall.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AllPairShortestPaths

#diameter, #edge_path, #node_path

Constructor Details

#initialize(graph, weight_key = nil) ⇒ FloydWarshall

Returns a new instance of FloydWarshall.

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
# File 'lib/shortest_path/floyd_warshall.rb', line 15

def initialize(graph, weight_key = nil)
  raise ArgumentError unless graph.is_a?(Graph)
  raise ArgumentError if (weight_key and not graph.has_edge_data_key?(weight_key))

  @graph, @weight_key = graph, weight_key
  @dist, @prev = {}, {}
  init_distance
  main_algorithm
end

Instance Attribute Details

#distObject (readonly)

Returns the value of attribute dist.



13
14
15
# File 'lib/shortest_path/floyd_warshall.rb', line 13

def dist
  @dist
end

#prevObject (readonly)

Returns the value of attribute prev.



13
14
15
# File 'lib/shortest_path/floyd_warshall.rb', line 13

def prev
  @prev
end