export method

This commit is contained in:
Achraf 2023-11-25 15:55:20 +01:00
parent d30c36204b
commit a72be9043c
2 changed files with 18 additions and 0 deletions

View file

@ -112,3 +112,19 @@ let from_file path =
close_in infile ;
final_graph
let export path graph =
let ff = open_out path in
fprintf ff "digraph {\n" ;
fprintf ff "rankdir=LR;\n";
fprintf ff "node [shape = circle]\n";
e_iter graph (fun arc -> fprintf ff "%d -> %d [label = \"%s\"];\n" arc.src arc.tgt arc.lbl);
fprintf ff "}"

View file

@ -12,6 +12,8 @@ val from_file: path -> string graph
* If necessary, use gmap (to be written by you) to prepare the input graph. *)
val write_file: path -> string graph -> unit
val export : path -> string graph -> unit
(* The format of files is compatible with the files generated by:
https://algorithms.discrete.ma.tum.de/graph-algorithms/flow-ford-fulkerson/index_en.html