premieres modifs projet

This commit is contained in:
Ferreira Sami-Koe 2024-11-22 16:50:43 +01:00
parent 310c42d911
commit ee566ee846
3 changed files with 25 additions and 1 deletions

View file

@ -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 *)
()

13
src/tools.ml Normal file
View file

@ -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. *)

8
src/tools.mli Normal file
View file

@ -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