refactor last tools.ml function
This commit is contained in:
parent
6f2abc2e72
commit
39df7c2e32
1 changed files with 6 additions and 1 deletions
|
@ -6,4 +6,9 @@ open Graph
|
||||||
(* returns a new graph having the same nodes than gr, but no arc. *)
|
(* returns a new graph having the same nodes than gr, but no arc. *)
|
||||||
let clone_nodes gr = n_fold gr new_node empty_graph;
|
let clone_nodes gr = n_fold gr new_node empty_graph;
|
||||||
(* maps all arcs of gr by function f *)
|
(* maps all arcs of gr by function f *)
|
||||||
let gmap gr f = e_fold gr (fun acc id1 id2 x -> add_arc id1 id2 (f x)) (clone_nodes gr);
|
let gmap gr f = e_fold gr (fun acc id1 id2 x -> add_arc id1 id2 (f x)) (clone_nodes gr);
|
||||||
|
|
||||||
|
let add_arc g id1 id2 n =
|
||||||
|
match find_arc g id1 id2 with
|
||||||
|
| None -> new_arc(g id1 id2 n graph)
|
||||||
|
| Some a -> new_arc(g id1 id2 n+a graph)
|
Loading…
Reference in a new issue