1 (**************************************************************************)
5 (* François Pottier, INRIA Rocquencourt *)
6 (* Yann Régis-Gianas, PPS, Université Paris Diderot *)
8 (* Copyright 2005-2008 Institut National de Recherche en Informatique *)
9 (* et en Automatique. All rights reserved. This file is distributed *)
10 (* under the terms of the Q Public License version 1.0, with the change *)
11 (* described in file LICENSE. *)
13 (**************************************************************************)
15 (* This module implements generic breadth-first search
16 over a graph with labeled edges. *)
20 (* This is the type of graph vertices. *)
24 (* This is the type of graph labels. *)
28 (* These allow marking a vertex and checking whether
31 val set_mark
: vertex
-> Mark.t
-> unit
32 val get_mark
: vertex
-> Mark.t
34 (* This is an iterator over the graph's entry vertices. *)
36 val entry
: (vertex
-> unit) -> unit
38 (* This provides access to a vertex' successors. *)
40 val successors
: (label
-> vertex
-> unit) -> vertex
-> unit
46 let queue : G.vertex
Queue.t
=
55 Mark.same mark
(G.get_mark vertex
)
58 G.set_mark vertex mark
;
59 Queue.add vertex
queue
64 Misc.qiter
(fun vertex
->
65 G.successors
(fun label son
->
66 if not
(visited son
) then begin
68 f
true vertex label son
71 f
false vertex label son