diff --git a/src/gfile.ml b/src/gfile.ml index d6a53ac..6b5503d 100644 --- a/src/gfile.ml +++ b/src/gfile.ml @@ -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 "}" + + + + + + diff --git a/src/gfile.mli b/src/gfile.mli index 465e693..aa76571 100644 --- a/src/gfile.mli +++ b/src/gfile.mli @@ -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