diff --git a/src/ftest.ml b/src/ftest.ml index 80489df..75c893c 100644 --- a/src/ftest.ml +++ b/src/ftest.ml @@ -1,4 +1,5 @@ open Gfile +open Tools let () = @@ -26,10 +27,12 @@ let () = in (* Open file *) - let graph = from_file infile in + let graph = clone_nodes (from_file infile) in + (* Rewrite the graph that has been read. *) let () = write_file outfile graph in + (*clone_nodes graph *) () diff --git a/src/tools.ml b/src/tools.ml new file mode 100644 index 0000000..8a84a65 --- /dev/null +++ b/src/tools.ml @@ -0,0 +1,13 @@ +(* Yes, we have to repeat open Graph. *) +open Graph + +(* assert false is of type ∀α.α, so the type-checker is happy. *) +let clone_nodes (gr: 'a graph) = + n_fold gr (fun acu id -> new_node acu id) empty_graph + +let gmap gr f = + let graph = e_fold gr (fun e -> f e) in graph (*utiliser fold pour appliquer la fonction f sur les noeuds et retourner un graphe*) + + +let add_arc _a _b _c _d = assert false +(* Replace _gr and _f by gr and f when you start writing the real function. *) \ No newline at end of file diff --git a/src/tools.mli b/src/tools.mli new file mode 100644 index 0000000..cb9db5e --- /dev/null +++ b/src/tools.mli @@ -0,0 +1,8 @@ +(* Read a graph from a file, + * Write a graph to a file. *) + +open Graph + +val clone_nodes: 'a graph -> 'b graph +val gmap: 'a graph -> ('a -> 'b) -> 'b graph +val add_arc: int graph -> id -> id -> int -> int graph \ No newline at end of file