feat : wrtie the function in tools
This commit is contained in:
parent
99c60192a7
commit
76c59abf84
1 changed files with 11 additions and 5 deletions
16
src/tools.ml
16
src/tools.ml
|
|
@ -1,7 +1,13 @@
|
|||
(* Yes, we have to repeat open Graph. *)
|
||||
open Graph
|
||||
|
||||
(* assert false is of type ∀α.α, so the type-checker is happy. *)
|
||||
let clone_nodes _gr = assert false
|
||||
let gmap _gr _f = assert false
|
||||
(* Replace _gr and _f by gr and f when you start writing the real function. *)
|
||||
(* returns a new graph having the same nodes than gr, but no arc *)
|
||||
let clone_nodes gr = n_fold gr new_node empty_graph
|
||||
|
||||
(* maps all arcs of gr by function f *)
|
||||
let gmap gr f = e_fold gr (fun gr arc -> new_arc gr {arc with lbl = f arc.lbl}) (clone_nodes gr)
|
||||
|
||||
(* adds n to the value of the arc between id1 and id2. If the arc does not exist, it is created *)
|
||||
let add_arc g id1 id2 n=
|
||||
match find_arc g id1 id2 with
|
||||
| Some _ -> g
|
||||
| None -> let arc = {src = id1; tgt = id2; lbl = n} in new_arc g arc
|
||||
Loading…
Reference in a new issue