mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 19:25:28 -05:00
bugfix in CCGraph.Dot.pp
This commit is contained in:
parent
02088a6dd7
commit
572f45560b
1 changed files with 9 additions and 7 deletions
|
|
@ -375,19 +375,21 @@ module Dot = struct
|
||||||
| `Label l -> Format.fprintf out "label=\"%s\"" l
|
| `Label l -> Format.fprintf out "label=\"%s\"" l
|
||||||
| `Other (name, value) -> Format.fprintf out "%s=\"%s\"" name value
|
| `Other (name, value) -> Format.fprintf out "%s=\"%s\"" name value
|
||||||
(* map from vertices to integers *)
|
(* map from vertices to integers *)
|
||||||
and get_id =
|
and get_node =
|
||||||
let count = ref 0 in
|
let count = ref 0 in
|
||||||
fun v ->
|
fun v ->
|
||||||
try (tbl.find v).id
|
try tbl.find v
|
||||||
with Not_found ->
|
with Not_found ->
|
||||||
let n = !count in
|
let node = {id= !count; explored=false} in
|
||||||
incr count;
|
incr count;
|
||||||
tbl.add v {explored=false; id=n};
|
tbl.add v node;
|
||||||
n
|
node
|
||||||
and vertex_explored v =
|
and vertex_explored v =
|
||||||
try (tbl.find v).explored
|
try (tbl.find v).explored
|
||||||
with Not_found -> false
|
with Not_found -> false
|
||||||
in
|
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 *)
|
(* the unique name of a vertex *)
|
||||||
let pp_vertex out v = Format.fprintf out "vertex_%d" (get_id v) in
|
let pp_vertex out v = Format.fprintf out "vertex_%d" (get_id v) in
|
||||||
(* print preamble *)
|
(* print preamble *)
|
||||||
|
|
@ -395,7 +397,7 @@ module Dot = struct
|
||||||
(* traverse *)
|
(* traverse *)
|
||||||
let tags = {
|
let tags = {
|
||||||
get_tag=vertex_explored;
|
get_tag=vertex_explored;
|
||||||
set_tag=(fun v -> ignore (get_id v)); (* allocate new ID *)
|
set_tag=set_explored; (* allocate new ID *)
|
||||||
} in
|
} in
|
||||||
let events = Traverse.Event.dfs_tag ~tags ~graph seq in
|
let events = Traverse.Event.dfs_tag ~tags ~graph seq in
|
||||||
Seq.iter
|
Seq.iter
|
||||||
|
|
@ -445,6 +447,6 @@ let divisors_graph = {
|
||||||
divisors (j+1) i yield
|
divisors (j+1) i yield
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
divisors 2 i
|
divisors 1 i
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue