Class: RGL::BellmanFordVisitor
- Inherits:
-
DijkstraVisitor
- Object
- DijkstraVisitor
- RGL::BellmanFordVisitor
- Defined in:
- lib/rgl/bellman_ford.rb
Overview
Bellman-Ford shortest paths algorithm has the following event points:
* examine_edge
* edge_relaxed
* edge_not_relaxed
* edge_minimized
* edge_not_minimized
Instance Attribute Summary
Attributes inherited from DijkstraVisitor
Attributes included from GraphVisitor
Attributes included from GraphWrapper
Instance Method Summary collapse
-
#initialize(graph) ⇒ BellmanFordVisitor
constructor
A new instance of BellmanFordVisitor.
Methods inherited from DijkstraVisitor
Methods included from GraphVisitor
#attach_distance_map, #finished_vertex?, #follow_edge?, included, #reset
Methods included from GraphVisitor::ClassMethods
Constructor Details
#initialize(graph) ⇒ BellmanFordVisitor
Returns a new instance of BellmanFordVisitor.
19 20 21 22 23 24 25 26 |
# File 'lib/rgl/bellman_ford.rb', line 19 def initialize(graph) super(graph) # by default, through an exception if a negative-weight cycle is detected @edge_not_minimized_event_handler = lambda do |u, v| raise ArgumentError.new("there is a negative-weight cycle including edge (#{u}, #{v})") end end |