Fix mistake in update_flow_graph
This commit is contained in:
parent
9f1c416d19
commit
a5d44a7fc8
3 changed files with 29 additions and 4 deletions
21
graphs/flow_graph1.txt
Normal file
21
graphs/flow_graph1.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
% This is a graph.
|
||||
|
||||
n 20 300 0
|
||||
n 200 300 1
|
||||
n 200 200 2
|
||||
n 200 400 3
|
||||
n 380 300 4
|
||||
n 380 200 5
|
||||
|
||||
e 0 2 0 5
|
||||
e 0 3 1 5
|
||||
e 0 1 2 5
|
||||
e 2 4 3 5
|
||||
e 3 4 4 5
|
||||
e 3 2 5 5
|
||||
e 3 1 6 5
|
||||
e 1 4 7 5
|
||||
e 1 5 8 5
|
||||
e 4 5 9 5
|
||||
|
||||
% End of graph
|
||||
|
|
@ -28,10 +28,15 @@ let () =
|
|||
|
||||
(* Open file *)
|
||||
let graph = from_file infile in
|
||||
let g = clone_nodes graph in
|
||||
(*let g = clone_nodes graph in*)
|
||||
|
||||
let flow_graph_1 = create_flow_graph graph in
|
||||
let flow_graph_2 = update_flow_graph flow_graph_1 (fun _ -> true) 5 in
|
||||
|
||||
let string_flow_graph = gmap flow_graph_2 (fun x -> string_of_int x) in
|
||||
|
||||
(* Rewrite the graph that has been read. *)
|
||||
let () = write_file outfile g in
|
||||
let () = write_file outfile string_flow_graph in
|
||||
|
||||
()
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ let update_flow_graph : int graph -> (int arc -> bool) -> int -> int graph =
|
|||
e_fold
|
||||
original_graph
|
||||
(fun acc_graph arc ->
|
||||
(* Perform some transformation or condition on the arc and accumulate the result in the new graph *)
|
||||
let modified_arc =
|
||||
if condition arc then
|
||||
{ arc with lbl = arc.lbl + increment }
|
||||
|
|
@ -27,7 +26,7 @@ let update_flow_graph : int graph -> (int arc -> bool) -> int -> int graph =
|
|||
arc
|
||||
in
|
||||
new_arc acc_graph modified_arc)
|
||||
empty_graph
|
||||
original_graph
|
||||
in
|
||||
new_graph
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue