add CCGraph.make and utils

This commit is contained in:
Simon Cruanes 2016-02-21 21:45:14 +01:00
parent 26298516b5
commit db1de6e6e6
2 changed files with 27 additions and 0 deletions

View file

@ -56,6 +56,16 @@ type ('v, 'e) t = {
type ('v, 'e) graph = ('v, 'e) t
let make ~origin ~dest f = {origin; dest; children=f; }
let make_labelled_tuple f =
make ~origin:(fun (x,_,_) -> x) ~dest:(fun (_,_,x) -> x)
(fun v yield -> f v (fun (l,v') -> yield (v,l,v')))
let make_tuple f =
make ~origin:fst ~dest:snd
(fun v yield -> f v (fun v' -> yield (v,v')))
(** Mutable bitset for values of type ['v] *)
type 'v tag_set = {
get_tag: 'v -> bool;

View file

@ -76,6 +76,23 @@ type ('v, 'e) t = {
type ('v, 'e) graph = ('v, 'e) t
val make :
origin:('e -> 'v) ->
dest:('e -> 'v) ->
('v -> 'e sequence) -> ('v, 'e) t
(** Make a graph by providing its fields
@since NEXT_RELEASE *)
val make_labelled_tuple :
('v -> ('a * 'v) sequence) -> ('v, ('v * 'a * 'v)) t
(** Make a graph with edges being triples [(origin,label,dest)]
@since NEXT_RELEASE *)
val make_tuple :
('v -> 'v sequence) -> ('v, ('v * 'v)) t
(** Make a graph with edges being pairs [(origin,dest)]
@since NEXT_RELEASE *)
(** Mutable tags from values of type ['v] to tags of type [bool] *)
type 'v tag_set = {
get_tag: 'v -> bool;