From 572f45560ba9ab6b3229eabdcfb7cf2010be0c9c Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 10 Jun 2015 15:11:09 +0200 Subject: [PATCH] bugfix in `CCGraph.Dot.pp` --- src/data/CCGraph.ml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/data/CCGraph.ml b/src/data/CCGraph.ml index e2e55415..498ef6ee 100644 --- a/src/data/CCGraph.ml +++ b/src/data/CCGraph.ml @@ -375,19 +375,21 @@ module Dot = struct | `Label l -> Format.fprintf out "label=\"%s\"" l | `Other (name, value) -> Format.fprintf out "%s=\"%s\"" name value (* map from vertices to integers *) - and get_id = + and get_node = let count = ref 0 in fun v -> - try (tbl.find v).id + try tbl.find v with Not_found -> - let n = !count in + let node = {id= !count; explored=false} in incr count; - tbl.add v {explored=false; id=n}; - n + tbl.add v node; + node and vertex_explored v = try (tbl.find v).explored with Not_found -> false in + let set_explored v = (get_node v).explored <- true + and get_id v = (get_node v).id in (* the unique name of a vertex *) let pp_vertex out v = Format.fprintf out "vertex_%d" (get_id v) in (* print preamble *) @@ -395,7 +397,7 @@ module Dot = struct (* traverse *) let tags = { get_tag=vertex_explored; - set_tag=(fun v -> ignore (get_id v)); (* allocate new ID *) + set_tag=set_explored; (* allocate new ID *) } in let events = Traverse.Event.dfs_tag ~tags ~graph seq in Seq.iter @@ -445,6 +447,6 @@ let divisors_graph = { divisors (j+1) i yield ) in - divisors 2 i + divisors 1 i ); }