Class: Doodl::FloydWarshall
- Inherits:
-
Object
- Object
- Doodl::FloydWarshall
- Includes:
- AllPairShortestPaths
- Defined in:
- lib/shortest_path/floyd_warshall.rb
Instance Attribute Summary collapse
-
#dist ⇒ Object
readonly
Returns the value of attribute dist.
-
#prev ⇒ Object
readonly
Returns the value of attribute prev.
Instance Method Summary collapse
-
#initialize(graph, weight_key = nil) ⇒ FloydWarshall
constructor
A new instance of FloydWarshall.
Methods included from AllPairShortestPaths
#diameter, #edge_path, #node_path
Constructor Details
#initialize(graph, weight_key = nil) ⇒ FloydWarshall
Returns a new instance of FloydWarshall.
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
#dist ⇒ Object (readonly)
Returns the value of attribute dist.
13 14 15 |
# File 'lib/shortest_path/floyd_warshall.rb', line 13 def dist @dist end |
#prev ⇒ Object (readonly)
Returns the value of attribute prev.
13 14 15 |
# File 'lib/shortest_path/floyd_warshall.rb', line 13 def prev @prev end |