fix : add the fact that we add the value if the arc already exists
This commit is contained in:
parent
ee1c4e7ba1
commit
7e93db8348
1 changed files with 8 additions and 2 deletions
10
src/tools.ml
10
src/tools.ml
|
|
@ -9,5 +9,11 @@ let gmap gr f = e_fold gr (fun gr arc -> new_arc gr {arc with lbl = f arc.lbl})
|
|||
(* 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
|
||||
| Some arc -> let new_lbl = arc.lbl + n in new_arc g {arc with lbl = new_lbl}
|
||||
| None -> let arc = {src = id1; tgt = id2; lbl = n} in new_arc g arc
|
||||
|
||||
|
||||
(* Tools to do :
|
||||
- Update graph : take a list and a value -> add this value to all arc in the list
|
||||
we must do a find_arc and if it doesn't find we try to do the arc in the other side with the value in negative
|
||||
-Find path : find a patch and return a list of arc and a value : the max of increase *)
|
||||
Loading…
Reference in a new issue