···11Ocamlgraph: a generic graph library for ocaml
22-Copyright (C) 2004-2008
22+Copyright (C) 2004-2010
33Sylvain Conchon, Jean-Christophe Filli�tre and Julien Signoles
4455This library is free software; you can redistribute it and/or
+11-11
src/topological.ml
···3636 H.remove degree x;
3737 Queue.push x todo
3838 in
3939- let rec walk acc =
3939+ let rec walk acc =
4040 if Queue.is_empty todo then
4141 (* let's find any node of minimal degree *)
4242 let min =
4343 H.fold
4444- (fun v d acc ->
4444+ (fun v d acc ->
4545 match acc with
4646 | None -> Some (v, d)
4747 | Some(_, min) -> if d < min then Some (v, d) else acc)
···5050 in
5151 match min with
5252 | None -> acc
5353- | Some(v, d) -> push v; walk acc
5353+ | Some(v, _) -> push v; walk acc
5454 else
5555 let v = Queue.pop todo in
5656 let acc = f v acc in
5757- G.iter_succ
5858- (fun x->
5959- try
5757+ G.iter_succ
5858+ (fun x->
5959+ try
6060 let d = H.find degree x in
6161 if d = 1 then push x else H.replace degree x (d-1)
6262- with Not_found ->
6262+ with Not_found ->
6363 (* [x] already visited *)
6464 ())
6565- g v;
6565+ g v;
6666 walk acc
6767 in
6868- G.iter_vertex
6969- (fun v ->
7070- let d = G.in_degree g v in
6868+ G.iter_vertex
6969+ (fun v ->
7070+ let d = G.in_degree g v in
7171 if d = 0 then Queue.push v todo
7272 else H.add degree v d)
7373 g;