mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-08 12:15:32 -05:00
add CCGraph.make and utils
This commit is contained in:
parent
26298516b5
commit
db1de6e6e6
2 changed files with 27 additions and 0 deletions
|
|
@ -56,6 +56,16 @@ type ('v, 'e) t = {
|
||||||
|
|
||||||
type ('v, 'e) graph = ('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] *)
|
(** Mutable bitset for values of type ['v] *)
|
||||||
type 'v tag_set = {
|
type 'v tag_set = {
|
||||||
get_tag: 'v -> bool;
|
get_tag: 'v -> bool;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,23 @@ type ('v, 'e) t = {
|
||||||
|
|
||||||
type ('v, 'e) graph = ('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] *)
|
(** Mutable tags from values of type ['v] to tags of type [bool] *)
|
||||||
type 'v tag_set = {
|
type 'v tag_set = {
|
||||||
get_tag: 'v -> bool;
|
get_tag: 'v -> bool;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue