added application support, removed deprecated "or" in tools, one bug still to fix (types not matching)

This commit is contained in:
rlacroix 2022-11-30 21:35:10 +01:00
parent 5ca008700e
commit 17d569adb5
19 changed files with 308 additions and 117 deletions

View file

@ -22,4 +22,12 @@ clean:
test: build
./ftest.native graphs/graph1 1 2 outfile
dot -Tsvg outfile > test.svg
dot -Tsvg outfile > test.svg
buildApp:
ocamlbuild appMedium.native
testApp: buildApp
./appMedium.native
dot -Tsvg outFileApp > outFileApp.svg

View file

@ -1,42 +1,44 @@
"Rule: ocaml dependencies mli (%=src/gfile )": "7\182\192g\020\238\188\b\211\164{\014\157\135\011\003"
"Rule: ocaml dependencies ml (%=src/appTools )": "\003~\021L\228\004\183\150J\023\129k$\243.y"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/display )": "\239\213\229\211j!\190#\027U\183\135\175^\143<"
"Resource: /home/alejeune/Documents/4ir/S1/Ocaml/FordFulkersonLeChameau/src/tools.mli": "9\173\222\177]e\245\229\131\151\020fsu\133@"
"Rule: ocaml dependencies mli (%=src/gfile )": "7\182\192g\020\238\188\b\211\164{\014\157\135\011\003"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/appTools.mli": "\132\r\001\182e@\193\228{\201\001T\028\193Z."
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/appTools.ml": "\237\194\004\240\234x)\235\141\229\133A#\210{X"
"Rule: ocaml dependencies mli (%=src/ioApp )": ",\249\026Y\003\016\207\2482j!Z\228\189e\166"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/gfile )": "\236O\148Y\157m\028\183\166?\231a\231\187u\132"
"Rule: ocaml dependencies ml (%=src/ftest )": "\129\231\129\216(|Io\133\186\180\221\250\\\208s"
"Rule: ocaml dependencies mli (%=src/display )": "\231~k=1\249%\182S0\233D\212\252\223\161"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/ftest.ml": "\134j\0044\254:\143\174\205\170s\173Q\171\183\185"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/fordFulkerson.ml": "qra\159@\212u\200\192\132V9-\127\2022"
"Rule: ocaml: mli -> cmi (%=src/display )": "\165\163&C\247\02392\222\141}\166\237\209\226\196"
"Rule: ocaml: mli -> cmi (%=src/graph )": ")2\159\205\136\031\251\145\0263\01878\001\b\134"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/graph.mli": "\253S\031\015\162|\210x\252\n \227\001{\133e"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/tools.ml": "\185\244\209\136L\1577;\191J\171\162M\135xa"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/fordFulkerson )": "NH\210[_\240)6\144(\177'?\001\2204"
"Rule: ocaml: cmx* & o* -> native (%=src/ftest )": "\190\238\178*\217\183\208\002\243m\177K\227T\138*"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/tools.ml": "\143\\\1796g(\028m\247\209\131_vDeU"
"Rule: ocaml: mli -> cmi (%=src/tools )": "\239.\206\1667\139\246~\227$\235l\012\210\208;"
"Rule: ocaml: mli -> cmi (%=src/fordFulkerson )": "v\184\208\237V\182T\138\168\207\20258\221\233s"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/ftest )": "S\179.\031\214@{\006P\197\221\"\003\t\173u"
"Resource: /home/alejeune/Documents/4ir/S1/Ocaml/FordFulkersonLeChameau/src/graph.ml": "\005\175.\2458\176E\202]\255\235=9\015\000\237"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/graph.ml": "\005\175.\2458\176E\202]\255\235=9\015\000\237"
"Rule: ocaml: mli -> cmi (%=src/gfile )": "\015\211&r\030l{}\183\187\236\2266\022\129\191"
"Resource: /home/alejeune/Documents/4ir/S1/Ocaml/FordFulkersonLeChameau/src/graph.mli": "\031\217\135\022\208\254\154\148\252)\210\130\174\215X\031"
"Resource: /home/alejeune/Documents/4ir/S1/Ocaml/FordFulkersonLeChameau/src/gfile.mli": "\203\249\163Ct\234\0067d}\142\011m8T`"
"Resource: /home/alejeune/Documents/4ir/S1/Ocaml/FordFulkersonLeChameau/src/tools.ml": "~[\186\208\199\129\006\030\012\196\245\183'\163\211&"
"Rule: ocaml dependencies ml (%=src/tools )": "\228\210\133\187`\193\179>\031\016\197\147\221\006j\017"
"Resource: /home/alejeune/Documents/4ir/S1/Ocaml/FordFulkersonLeChameau/src/ftest.ml": "~\190 \235\142\210\r\222\253\136>\194\180\207\183\168"
"Rule: ocaml: ml -> cmo & cmi (%=src/ftest )": "^\163\159\019\141kEw\168\171,\156\252=X\006"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/ioApp.mli": "*\027\197C\000\030}\147\219Kx\159\153\2463\245"
"Rule: ocaml: mli -> cmi (%=src/appTools )": "\006a$\191W\146\176aU0w_\197\181d-"
"Rule: ocaml dependencies ml (%=src/tools )": ",\255!)\2477ygb7\022\204V\143/$"
"Rule: ocaml: mli -> cmi (%=src/ioApp )": "\202\189io\239\154Dl\130Z\150\029\238\212\163\249"
"Rule: ocaml dependencies ml (%=src/ioApp )": "\179o\011\147\170\140\133:*\005P\152O\014K\232"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/ioApp.ml": "\170\147\162w\171\210QN\189\137\137-\227\184\222j"
"Rule: ocaml dependencies mli (%=src/fordFulkerson )": "\022\200\166Dz0\003\233z\198y\144S\162\2034"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/fordFulkerson.mli": "_;(\155\176\"\225\011\230\191\031M\168\250\219\170"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/display.mli": "\1933\002\200+\198\166\181\251\020[Kl\1395\244"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/tools )": "z\158\235\155v\003\214Q\150\t\224\"\026\246(\158"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/tools )": "@\029k\227\011N\245M\025S\161\203\212\156\191F"
"Rule: ocaml dependencies mli (%=src/appTools )": "\131\213\134\023\170\184\227\194y\196[v\172=A\210"
"Rule: ocaml: ml -> cmo & cmi (%=src/appMedium )": "0Z<\189\021\232\163\188bE\025E\129:\011\179"
"Rule: ocaml dependencies ml (%=src/fordFulkerson )": "P\128\241\162\216\228\240\163<\168\241\235\129v\231\185"
"Resource: /home/alejeune/Documents/4ir/S1/Ocaml/FordFulkersonLeChameau/src/gfile.ml": "\1966\177\141\185,fpl\1987gT\128b\028"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/gfile.ml": "\1966\177\141\185,fpl\1987gT\128b\028"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/appTools )": "Z>\162l4\144\001\029D\tv\210\237\202b+"
"Rule: ocaml dependencies ml (%=src/appMedium )": "\rk\244M\254v'3T489m\239\247\217"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/tools.mli": "\025v\144\241\237\241\b\248\197tD\012\171\216\202\148"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/graph )": "\190\tV\232\254i\031+\141\154\168\219\155n\156C"
"Rule: ocaml dependencies ml (%=src/graph )": "\137kk#\140\236\011\255?\132T\225M\018\169\224"
"Rule: ocaml dependencies mli (%=src/graph )": "\012\213_n\023=\207kZ+\251(^M\2028"
"Rule: ocaml dependencies ml (%=src/display )": "\150I\199\147\226\208\148\192\184y\253\190\201\006>\168"
"Rule: ocaml dependencies mli (%=src/graph )": "\012\213_n\023=\207kZ+\251(^M\2028"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/gfile.mli": "\203\249\163Ct\234\0067d}\142\011m8T`"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/appMedium.ml": "\174H\007\251\150\248u\185\140\197\1745 c\204\213"
"Rule: ocaml dependencies ml (%=src/gfile )": "U4(<\t=rQ\240c\0278\231N\1949"
"Rule: ocaml dependencies mli (%=src/tools )": "\151\181\0055\199\150&\017\021_\215\015\215\018\027+"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/display.ml": "\253\183m\179\227\189\240\189Z\198>\208jt\007#"

View file

@ -1,8 +1,8 @@
### Starting build.
# Target: src/ftest.ml.depends, tags: { extension:ml, file:src/ftest.ml, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/ftest.ml > src/ftest.ml.depends
# Target: src/display.mli.depends, tags: { extension:mli, file:src/display.mli, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/display.mli > src/display.mli.depends # cached
# Target: src/appMedium.ml.depends, tags: { extension:ml, file:src/appMedium.ml, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/appMedium.ml > src/appMedium.ml.depends # cached
# Target: src/appTools.mli.depends, tags: { extension:mli, file:src/appTools.mli, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/appTools.mli > src/appTools.mli.depends # cached
# Target: src/gfile.mli.depends, tags: { extension:mli, file:src/gfile.mli, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/gfile.mli > src/gfile.mli.depends # cached
# Target: src/graph.mli.depends, tags: { extension:mli, file:src/graph.mli, include, ocaml, ocamldep, quiet, traverse }
@ -11,20 +11,28 @@
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/graph.cmi src/graph.mli # cached
# Target: src/gfile.cmi, tags: { byte, compile, extension:mli, file:src/gfile.mli, include, interf, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/gfile.cmi src/gfile.mli # cached
# Target: src/display.cmi, tags: { byte, compile, extension:mli, file:src/display.mli, include, interf, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/display.cmi src/display.mli # cached
# Target: src/fordFulkerson.mli.depends, tags: { extension:mli, file:src/fordFulkerson.mli, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/fordFulkerson.mli > src/fordFulkerson.mli.depends # cached
# Target: src/tools.mli.depends, tags: { extension:mli, file:src/tools.mli, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/tools.mli > src/tools.mli.depends # cached
# Target: src/tools.cmi, tags: { byte, compile, extension:mli, file:src/tools.mli, include, interf, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/tools.cmi src/tools.mli # cached
# Target: src/appTools.cmi, tags: { byte, compile, extension:mli, file:src/appTools.mli, include, interf, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/appTools.cmi src/appTools.mli # cached
# Target: src/display.mli.depends, tags: { extension:mli, file:src/display.mli, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/display.mli > src/display.mli.depends # cached
# Target: src/display.cmi, tags: { byte, compile, extension:mli, file:src/display.mli, include, interf, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/display.cmi src/display.mli # cached
# Target: src/fordFulkerson.mli.depends, tags: { extension:mli, file:src/fordFulkerson.mli, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/fordFulkerson.mli > src/fordFulkerson.mli.depends # cached
# Target: src/fordFulkerson.cmi, tags: { byte, compile, extension:mli, file:src/fordFulkerson.mli, include, interf, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/fordFulkerson.cmi src/fordFulkerson.mli # cached
# Target: src/ftest.cmo, tags: { byte, compile, extension:cmo, extension:ml, file:src/ftest.cmo, file:src/ftest.ml, implem, include, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/ftest.cmo src/ftest.ml
# Target: src/display.ml.depends, tags: { extension:ml, file:src/display.ml, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/display.ml > src/display.ml.depends # cached
# Target: src/ioApp.mli.depends, tags: { extension:mli, file:src/ioApp.mli, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/ioApp.mli > src/ioApp.mli.depends
# Target: src/ioApp.cmi, tags: { byte, compile, extension:mli, file:src/ioApp.mli, include, interf, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/ioApp.cmi src/ioApp.mli
# Target: src/appMedium.cmo, tags: { byte, compile, extension:cmo, extension:ml, file:src/appMedium.cmo, file:src/appMedium.ml, implem, include, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/appMedium.cmo src/appMedium.ml
# Target: src/appTools.ml.depends, tags: { extension:ml, file:src/appTools.ml, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/appTools.ml > src/appTools.ml.depends # cached
# Target: src/gfile.ml.depends, tags: { extension:ml, file:src/gfile.ml, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/gfile.ml > src/gfile.ml.depends # cached
# Target: src/graph.ml.depends, tags: { extension:ml, file:src/graph.ml, include, ocaml, ocamldep, quiet, traverse }
@ -33,18 +41,37 @@
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/graph.cmx src/graph.ml # cached
# Target: src/gfile.cmx, tags: { compile, extension:cmx, extension:ml, file:src/gfile.cmx, file:src/gfile.ml, implem, include, native, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/gfile.cmx src/gfile.ml # cached
# Target: src/display.cmx, tags: { compile, extension:cmx, extension:ml, file:src/display.cmx, file:src/display.ml, implem, include, native, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/display.cmx src/display.ml # cached
# Target: src/fordFulkerson.ml.depends, tags: { extension:ml, file:src/fordFulkerson.ml, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/fordFulkerson.ml > src/fordFulkerson.ml.depends # cached
# Target: src/tools.ml.depends, tags: { extension:ml, file:src/tools.ml, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/tools.ml > src/tools.ml.depends # cached
# Target: src/tools.cmx, tags: { compile, extension:cmx, extension:ml, file:src/tools.cmx, file:src/tools.ml, implem, include, native, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/tools.cmx src/tools.ml # cached
# Target: src/appTools.cmx, tags: { compile, extension:cmx, extension:ml, file:src/appTools.cmx, file:src/appTools.ml, implem, include, native, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/appTools.cmx src/appTools.ml # cached
# Target: src/display.ml.depends, tags: { extension:ml, file:src/display.ml, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/display.ml > src/display.ml.depends # cached
# Target: src/display.cmx, tags: { compile, extension:cmx, extension:ml, file:src/display.cmx, file:src/display.ml, implem, include, native, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/display.cmx src/display.ml # cached
# Target: src/fordFulkerson.ml.depends, tags: { extension:ml, file:src/fordFulkerson.ml, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/fordFulkerson.ml > src/fordFulkerson.ml.depends # cached
# Target: src/fordFulkerson.cmx, tags: { compile, extension:cmx, extension:ml, file:src/fordFulkerson.cmx, file:src/fordFulkerson.ml, implem, include, native, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/fordFulkerson.cmx src/fordFulkerson.ml # cached
# Target: src/ftest.cmx, tags: { compile, extension:cmx, extension:ml, file:src/ftest.cmx, file:src/ftest.ml, implem, include, native, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/ftest.cmx src/ftest.ml
# Target: src/ftest.native, tags: { dont_link_with, extension:native, file:src/ftest.native, include, link, native, ocaml, program, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -I src src/graph.cmx src/gfile.cmx src/display.cmx src/tools.cmx src/fordFulkerson.cmx src/ftest.cmx -o src/ftest.native
# Compilation successful.
# Target: src/ioApp.ml.depends, tags: { extension:ml, file:src/ioApp.ml, include, ocaml, ocamldep, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/ioApp.ml > src/ioApp.ml.depends # cached
# Target: src/ioApp.cmx, tags: { compile, extension:cmx, extension:ml, file:src/ioApp.cmx, file:src/ioApp.ml, implem, include, native, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/ioApp.cmx src/ioApp.ml
+ /home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/ioApp.cmx src/ioApp.ml
File "src/ioApp.ml", line 1:
Error: The implementation src/ioApp.ml
does not match the interface src/ioApp.cmi:
Values do not match:
val enterChildren : int -> 'a -> (int * string * string list) list
is not included in
val enterChildren : int -> int -> (int * string * int list) list
The type int -> int -> (int * string * string list) list
is not compatible with the type
int -> int -> (int * string * int list) list
Type string is not compatible with type int
File "src/ioApp.mli", line 6, characters 0-63: Expected declaration
File "src/ioApp.ml", line 32, characters 4-17: Actual declaration
Command exited with code 2.
# Compilation unsuccessful.

Binary file not shown.

Binary file not shown.

View file

@ -1,46 +0,0 @@
open Gfile
open Tools
open Display
open FordFulkerson
let () =
(* Check the number of command-line arguments
*)
if Array.length Sys.argv <> 5 then
begin
Printf.printf
"\n ✻ Usage: %s infile source sink outfile\n\n%s%!" Sys.argv.(0)
(" 🟄 infile : input file containing a graph\n" ^
" 🟄 source : identifier of the source vertex (used by the ford-fulkerson algorithm)\n" ^
" 🟄 sink : identifier of the sink vertex (ditto)\n" ^
" 🟄 outfile : output file in which the result should be written.\n\n") ;
exit 0
end ;
(* Arguments are : infile(1) source-id(2) sink-id(3) outfile(4) *)
let infile = Sys.argv.(1)
and outfile = Sys.argv.(4)
(* These command-line arguments are not used for the moment. *)
and _source = int_of_string Sys.argv.(2)
and _sink = int_of_string Sys.argv.(3)
in
(* Open file *)
let graph = from_file infile in
let graphInt = gmap graph int_of_string in
let graphSolved = main graphInt 0 3 in
let () = exportDifference graphInt graphSolved outfile in
()
(* Rewrite the graph that has been read.
let () = write_file outfile graphDot in
()
*)

View file

@ -1 +0,0 @@
src/ftest.ml: Array Display FordFulkerson Gfile Printf Sys Tools

Binary file not shown.

Binary file not shown.

View file

@ -1 +0,0 @@
/home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/_build/src/ftest.native

18
outFileApp Normal file
View file

@ -0,0 +1,18 @@
digraph finite_state_machine {
fontname="Helvetica,Arial,sans-serif"
node [fontname="Helvetica,Arial,sans-serif"]
edge [fontname="Helvetica,Arial,sans-serif"]
rankdir=LR;
node [shape = circle];
3 -> 0 [label = "1"];
2 -> 0 [label = "1"];
1 -> 0 [label = "1"];
}

58
outFileApp.svg Normal file
View file

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.50.0 (0)
-->
<!-- Title: finite_state_machine Pages: 1 -->
<svg width="124pt" height="152pt"
viewBox="0.00 0.00 124.00 152.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 148)">
<title>finite_state_machine</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-148 120,-148 120,4 -4,4"/>
<!-- 3 -->
<g id="node1" class="node">
<title>3</title>
<ellipse fill="none" stroke="black" cx="18" cy="-126" rx="18" ry="18"/>
<text text-anchor="middle" x="18" y="-122.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">3</text>
</g>
<!-- 0 -->
<g id="node2" class="node">
<title>0</title>
<ellipse fill="none" stroke="black" cx="98" cy="-72" rx="18" ry="18"/>
<text text-anchor="middle" x="98" y="-68.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">0</text>
</g>
<!-- 3&#45;&gt;0 -->
<g id="edge1" class="edge">
<title>3&#45;&gt;0</title>
<path fill="none" stroke="black" d="M33.31,-116.1C44.74,-108.18 60.99,-96.93 74.21,-87.78"/>
<polygon fill="black" stroke="black" points="76.55,-90.41 82.78,-81.84 72.57,-84.66 76.55,-90.41"/>
<text text-anchor="middle" x="58" y="-103.8" font-family="Helvetica,Arial,sans-serif" font-size="14.00">1</text>
</g>
<!-- 2 -->
<g id="node3" class="node">
<title>2</title>
<ellipse fill="none" stroke="black" cx="18" cy="-72" rx="18" ry="18"/>
<text text-anchor="middle" x="18" y="-68.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">2</text>
</g>
<!-- 2&#45;&gt;0 -->
<g id="edge2" class="edge">
<title>2&#45;&gt;0</title>
<path fill="none" stroke="black" d="M36.31,-72C46.11,-72 58.58,-72 69.67,-72"/>
<polygon fill="black" stroke="black" points="69.74,-75.5 79.74,-72 69.74,-68.5 69.74,-75.5"/>
<text text-anchor="middle" x="58" y="-75.8" font-family="Helvetica,Arial,sans-serif" font-size="14.00">1</text>
</g>
<!-- 1 -->
<g id="node4" class="node">
<title>1</title>
<ellipse fill="none" stroke="black" cx="18" cy="-18" rx="18" ry="18"/>
<text text-anchor="middle" x="18" y="-14.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">1</text>
</g>
<!-- 1&#45;&gt;0 -->
<g id="edge3" class="edge">
<title>1&#45;&gt;0</title>
<path fill="none" stroke="black" d="M33.31,-27.9C44.74,-35.82 60.99,-47.07 74.21,-56.22"/>
<polygon fill="black" stroke="black" points="72.57,-59.34 82.78,-62.16 76.55,-53.59 72.57,-59.34"/>
<text text-anchor="middle" x="58" y="-49.8" font-family="Helvetica,Arial,sans-serif" font-size="14.00">1</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

16
src/appMedium.ml Normal file
View file

@ -0,0 +1,16 @@
open Gfile
open Tools
open Display
open FordFulkerson
open IoApp
open AppTools
let () =
let xs = List.rev (enterAllChoices ()) in
let () = displayAllChoices xs in
();
let g = buildGraph xs in
let () = exportBase g "./outFileApp" in
()

18
src/appTools.ml Normal file
View file

@ -0,0 +1,18 @@
open Graph
open Gfile
open Tools
let buildGraph xs =
let g = new_node empty_graph 0 (*Defines the end*)
in
let rec inner acc = function
| [] -> acc
| (_,id) :: xs -> inner (add_arc (new_node acc id) id 0 1) xs
in
inner g xs
let getMaximumNodeId g =
n_fold g (fun x id -> max x id) 0
let thrd = function
| (_, _, a ) -> a

9
src/appTools.mli Normal file
View file

@ -0,0 +1,9 @@
open Graph
open Gfile
open Tools
val buildGraph : (string * int) list -> int graph
val getMaximumNodeId : 'a graph -> int
val thrd : ('a * 'b * 'c) -> 'c

View file

@ -2,45 +2,42 @@
open Tools
open Display
open FordFulkerson
open IoApp
let () =
(* Check the number of command-line arguments
*)
if Array.length Sys.argv <> 5 then
(* Check the number of command-line arguments*)
if Array.length Sys.argv <> 5 then
begin
Printf.printf
"\n ✻ Usage: %s infile source sink outfile\n\n%s%!" Sys.argv.(0)
(" 🟄 infile : input file containing a graph\n" ^
" 🟄 source : identifier of the source vertex (used by the ford-fulkerson algorithm)\n" ^
" 🟄 sink : identifier of the sink vertex (ditto)\n" ^
" 🟄 outfile : output file in which the result should be written.\n\n") ;
exit 0
Printf.printf
"\n ✻ Usage: %s infile source sink outfile\n\n%s%!" Sys.argv.(0)
(" 🟄 infile : input file containing a graph\n" ^
" 🟄 source : identifier of the source vertex (used by the ford-fulkerson algorithm)\n" ^
" 🟄 sink : identifier of the sink vertex (ditto)\n" ^
" 🟄 outfile : output file in which the result should be written.\n\n") ;
exit 0
end ;
(* Arguments are : infile(1) source-id(2) sink-id(3) outfile(4) *)
(* Arguments are : infile(1) source-id(2) sink-id(3) outfile(4) *)
let infile = Sys.argv.(1)
and outfile = Sys.argv.(4)
let infile = Sys.argv.(1)
and outfile = Sys.argv.(4)
(* These command-line arguments are not used for the moment. *)
and _source = int_of_string Sys.argv.(2)
and _sink = int_of_string Sys.argv.(3)
in
(* These command-line arguments are not used for the moment. *)
and _source = int_of_string Sys.argv.(2)
and _sink = int_of_string Sys.argv.(3)
in
(* Open file *)
let graph = from_file infile in
let xs = List.rev (enterAllChoices ()) in
let () = displayAllChoices xs in
();
let graphInt = gmap graph int_of_string in
(* Open file *)
let graph = from_file infile in
let graphSolved = main graphInt 0 3 in
let graphInt = gmap graph int_of_string in
let graphSolved = main graphInt 0 3 in
let () = exportDifference graphInt graphSolved outfile in
()
(* Rewrite the graph that has been read.
let () = write_file outfile graphDot in
()
*)
let () = exportDifference graphInt graphSolved outfile in
()

58
src/ioApp.ml Normal file
View file

@ -0,0 +1,58 @@
(* Prompts the user to enter all activities and stores them in a (id, name) list*)
let enterAllChoices () =
let rec inner xs i =
let str = read_line () in
if str = ""
then
xs
else
inner ((str,i) :: xs) (i+1)
in
print_string "Enter the next possible choices for the children separated \
by new lines, hit enter to finish \n";
inner [] 1
(* Displays all of the activities alongside their id*)
let displayAllChoices xs =
let rec inner i acc = function
| [] -> acc
| x :: xs -> inner (i+1) ( acc ^ (string_of_int i) ^ " : " ^ x ^ "\n") xs
in
print_string (inner 1 "" (List.map (fun x -> fst x) xs))
(* Prompts the user to enter all children's names the activities they are
interested in and returns a (id, name, id list) list.
Takes in input the number of the previously assigned nodes' maximum id*
and the list of activities) *)
let enterChildren idPrev listActivities =
let rec inner xs i =
let str = read_line ()
in
if str = ""
then
xs
else
(*if str = "1"
then
displayAllChoices listActivities
else*)
let inputs = List.filter (fun s -> s <> "") (String.split_on_char ' ' str)
in
inner ((i, (List.hd inputs), (List.tl inputs)) :: xs) (i+1)
in
print_string "Enter the name of the child followed by the ids of the \
activities they are interested in. type \'1\' to list the activities\n";
inner [] (idPrev+1)
(* Takes an already built graph and adds it capacities
(i.e. : the number of people that can register for a said activity *)
(*let setCapcities g = TODO Complete *)

28
src/ioApp.mli Normal file
View file

@ -0,0 +1,28 @@
val enterAllChoices: unit -> (string * int) list
val displayAllChoices: (string * int) list -> unit
(*TODO : figure out error message :
ocamlbuild appMedium.native
+ /home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/ioApp.cmx src/ioApp.ml
File "src/ioApp.ml", line 1:
Error: The implementation src/ioApp.ml
does not match the interface src/ioApp.cmi:
Values do not match:
val enterChildren : int -> 'a -> (int * string * string list) list
is not included in
val enterChildren : int -> int -> (int * string * int list) list
The type int -> int -> (int * string * string list) list
is not compatible with the type
int -> int -> (int * string * int list) list
Type string is not compatible with type int
File "src/ioApp.mli", line 6, characters 0-63: Expected declaration
File "src/ioApp.ml", line 32, characters 4-17: Actual declaration
Command exited with code 2.
Compilation unsuccessful after building 30 targets (26 cached) in 00:00:00.
make: *** [Makefile:29: buildApp] Error 10*)
val enterChildren: int -> (string * int) list -> (int * string * int list) list
(*TODO val setCapcities : int graph -> int graph *)

View file

@ -41,7 +41,7 @@ let maxCapaGraph g =
(*Checks that no null or negative edge exists,
returns the graph unchanged in this case*)
let testGraphSanity g =
if e_fold g (fun x id1 id2 a -> x or a < 1) false
if e_fold g (fun x id1 id2 a -> x || a < 1) false
then
failwith "Graph wrongly managed"
else