Sha256: a8864d07dcb1d858f0773cb8fc675827733314f71e15e96e0cc93eb7ec2c85f0
Contents?: true
Size: 749 Bytes
Versions: 17
Compression:
Stored size: 749 Bytes
Contents
require 'rgl/base' require 'rgl/graph_visitor' module RGL # Dijkstra shortest path algorithm has the following event points: # # * examine_vertex # * examine_edge # * edge_relaxed # * edge_not_relaxed # * finish_vertex # class DijkstraVisitor include GraphVisitor attr_accessor :distance_map, :parents_map def_event_handlers :edge_relaxed, :edge_not_relaxed # Returns visitor into initial state. # def reset super @distance_map = Hash.new(INFINITY) @parents_map = {} end # Initializes visitor with a new source. # def set_source(source) reset color_map[source] = :GRAY distance_map[source] = 0 end end # DijkstraVisitor end # RGL
Version data entries
17 entries across 17 versions & 1 rubygems