Commit f5fd06e5 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Generalized [Dijkstra] to allow multiple source vertices.

parent 5214eff9
......@@ -254,7 +254,7 @@ let backward (s', z) : property =
let hash (s, z) = Hashtbl.hash (Lr1.number s, z)
type label = int * Terminal.t Seq.seq
let weight (w, _) = w
let source = (s', z)
let sources f = f (s', z)
let successors edge (s', z) =
match Lr1.incoming_symbol s' with
| None ->
......
......@@ -16,9 +16,9 @@ module Make (G : sig
val weight: label -> int
(* The source vertex. *)
(* The source vertex (or vertices). *)
val source: vertex
val sources: (vertex -> unit) -> unit
(* This provides access to a vertex' successors. *)
......@@ -55,9 +55,11 @@ end) = struct
let distance v =
try H.find dist v with Not_found -> max_int
in
(* Insert the initial vertex. *)
PQ.add queue (0, source, []);
H.add dist source 0;
(* Insert the initial vertices. *)
sources (fun source ->
PQ.add queue (0, source, []);
H.add dist source 0
);
(* As long as the queue is nonempty, ... *)
while not (PQ.is_empty queue) do
(* Extract one vertex. *)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment