added inputs support. The application can read its input. Missing the output part.

This commit is contained in:
rlacroix 2022-12-09 21:12:37 +01:00
parent 17d569adb5
commit a85a66c9a7
10 changed files with 247 additions and 124 deletions

View file

@ -1,44 +1,47 @@
"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<"
"Rule: ocaml dependencies ml (%=src/appTools )": "\183\148#t\166\132\168\206#\210\238[Q2\b["
"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/display )": "\239\213\229\211j!\190#\027U\183\135\175^\143<"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/appTools.mli": "\150\255\014\015\006\217\135\239\138\221\031\024D\175\187\240"
"Rule: ocaml dependencies mli (%=src/ioApp )": "\015p\211\144\234B\152\220\232~\227\1799o\140:"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/appTools.ml": "^\251~s!\164;8\176\224\157\152K\214\135\223"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/gfile )": "\236O\148Y\157m\028\183\166?\231a\231\187u\132"
"Rule: ocaml: cmx* & o* -> native (%=src/appMedium )": "\007g\183Z\031\194]+_\241X\200\rD\023\246"
"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/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"
"Rule: ocaml: mli -> cmi (%=src/display )": "\165\163&C\247\02392\222\141}\166\237\209\226\196"
"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"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/fordFulkerson )": "NH\210[_\240)6\144(\177'?\001\2204"
"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: ml & cmi -> cmx & o (%=src/fordFulkerson )": "NH\210[_\240)6\144(\177'?\001\2204"
"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"
"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/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-"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/ioApp.mli": "\151\003\019\151\016\160\201G\158\215\195\0282\192\193\179"
"Rule: ocaml: mli -> cmi (%=src/appTools )": "\254\007-\022GJ\148\228/\220\"#%3\186\024"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/appMedium )": "PM(\023e6\192\145\205\140Xf\241\184\028#"
"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"
"Rule: ocaml: mli -> cmi (%=src/ioApp )": "\157\160\238I\0164\025\190\144\018\016\222\162B\006i"
"Rule: ocaml dependencies ml (%=src/ioApp )": "*\222\b4~[\166S\002\239\253\162\252\227\250\130"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/ioApp.ml": "\241W\154\212\017'L|v.pw\243\253\206/"
"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"
"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/display.mli": "\1933\002\200+\198\166\181\251\020[Kl\1395\244"
"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"
"Rule: ocaml dependencies mli (%=src/appTools )": "\144I\155\245\193\219\140\169\228\151\003d\023\029\176\247"
"Rule: ocaml: ml -> cmo & cmi (%=src/appMedium )": "\196\219\130\186p\144\141Q\228\142\217\015\133{\154\168"
"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"
"Rule: ocaml dependencies ml (%=src/fordFulkerson )": "P\128\241\162\216\228\240\163<\168\241\235\129v\231\185"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/appTools )": ")\214w`^\253B\200\150,\219\173\0174\006d"
"Rule: ocaml dependencies ml (%=src/appMedium )": "\142\163\229\252\003U{\202!:\138\184$\247ZN"
"Rule: ocaml: ml & cmi -> cmx & o (%=src/ioApp )": "\193\015X--\018\239\025\016\241\025\225\172jI\206"
"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 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"
"Rule: ocaml dependencies ml (%=src/display )": "\150I\199\147\226\208\148\192\184y\253\190\201\006>\168"
"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"
"Resource: /home/chepycou/Documents/cours/4-IR/functionalProgramming/Projet/repoGit/ocaml-maxflow-project/src/appMedium.ml": "\216\2227\174z\bw\1511b\183\194j\156\201s"
"Rule: ocaml dependencies mli (%=src/tools )": "\151\181\0055\199\150&\017\021_\215\015\215\018\027+"
"Rule: ocaml dependencies ml (%=src/gfile )": "U4(<\t=rQ\240c\0278\231N\1949"
"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,6 +1,6 @@
### Starting build.
# 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
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/appMedium.ml > src/appMedium.ml.depends
# 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 }
@ -26,11 +26,16 @@
# 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/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
/home/chepycou/.opam/4.14.0/bin/ocamldep.opt -modules src/ioApp.mli > src/ioApp.mli.depends # cached
# 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
/home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/ioApp.cmi src/ioApp.mli # cached
# 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
+ /home/chepycou/.opam/4.14.0/bin/ocamlc.opt -c -I src -o src/appMedium.cmo src/appMedium.ml
File "src/appMedium.ml", line 25, characters 12-18:
25 | let gFinal = main gComplete (getMaximumNodeId gComplete) 0 in
^^^^^^
Warning 26 [unused-var]: unused variable gFinal.
# 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 }
@ -58,20 +63,14 @@
# 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.
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/ioApp.cmx src/ioApp.ml # cached
# Target: src/appMedium.cmx, tags: { compile, extension:cmx, extension:ml, file:src/appMedium.cmx, file:src/appMedium.ml, implem, include, native, ocaml, quiet, traverse }
/home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/appMedium.cmx src/appMedium.ml
+ /home/chepycou/.opam/4.14.0/bin/ocamlopt.opt -c -I src -o src/appMedium.cmx src/appMedium.ml
File "src/appMedium.ml", line 25, characters 12-18:
25 | let gFinal = main gComplete (getMaximumNodeId gComplete) 0 in
^^^^^^
Warning 26 [unused-var]: unused variable gFinal.
# Target: src/appMedium.native, tags: { dont_link_with, extension:native, file:src/appMedium.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/tools.cmx src/appTools.cmx src/display.cmx src/fordFulkerson.cmx src/ioApp.cmx src/appMedium.cmx -o src/appMedium.native
# Compilation successful.

1
appMedium.native Symbolic link
View file

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

View file

@ -12,7 +12,13 @@
node [shape = circle];
3 -> 0 [label = "1"];
2 -> 0 [label = "1"];
1 -> 0 [label = "1"];
4 -> 3 [label = "1"];
4 -> 2 [label = "1"];
4 -> 1 [label = "1"];
6 -> 4 [label = "1"];
6 -> 5 [label = "1"];
5 -> 2 [label = "1"];
3 -> 0 [label = "4"];
2 -> 0 [label = "3"];
1 -> 0 [label = "2"];
}

View file

@ -4,55 +4,115 @@
<!-- 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)">
<svg width="284pt" height="159pt"
viewBox="0.00 0.00 284.00 159.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 155)">
<title>finite_state_machine</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-148 120,-148 120,4 -4,4"/>
<!-- 3 -->
<polygon fill="white" stroke="transparent" points="-4,4 -4,-155 280,-155 280,4 -4,4"/>
<!-- 4 -->
<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>
<title>4</title>
<ellipse fill="none" stroke="black" cx="98" cy="-77" rx="18" ry="18"/>
<text text-anchor="middle" x="98" y="-73.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">4</text>
</g>
<!-- 0 -->
<!-- 3 -->
<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>
<title>3</title>
<ellipse fill="none" stroke="black" cx="178" cy="-79" rx="18" ry="18"/>
<text text-anchor="middle" x="178" y="-75.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">3</text>
</g>
<!-- 3&#45;&gt;0 -->
<!-- 4&#45;&gt;3 -->
<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>
<title>4&#45;&gt;3</title>
<path fill="none" stroke="black" d="M116.31,-77.44C126.11,-77.7 138.58,-78.01 149.67,-78.3"/>
<polygon fill="black" stroke="black" points="149.65,-81.8 159.74,-78.56 149.83,-74.8 149.65,-81.8"/>
<text text-anchor="middle" x="138" y="-81.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>
<ellipse fill="none" stroke="black" cx="178" cy="-25" rx="18" ry="18"/>
<text text-anchor="middle" x="178" y="-21.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">2</text>
</g>
<!-- 2&#45;&gt;0 -->
<!-- 4&#45;&gt;2 -->
<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>
<title>4&#45;&gt;2</title>
<path fill="none" stroke="black" d="M113.31,-67.46C124.67,-59.89 140.78,-49.14 153.96,-40.36"/>
<polygon fill="black" stroke="black" points="156.14,-43.11 162.52,-34.65 152.26,-37.29 156.14,-43.11"/>
<text text-anchor="middle" x="138" y="-55.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>
<ellipse fill="none" stroke="black" cx="178" cy="-133" rx="18" ry="18"/>
<text text-anchor="middle" x="178" y="-129.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">1</text>
</g>
<!-- 4&#45;&gt;1 -->
<g id="edge3" class="edge">
<title>4&#45;&gt;1</title>
<path fill="none" stroke="black" d="M113.31,-87.27C124.85,-95.56 141.3,-107.37 154.59,-116.91"/>
<polygon fill="black" stroke="black" points="152.62,-119.8 162.78,-122.79 156.7,-114.12 152.62,-119.8"/>
<text text-anchor="middle" x="138" y="-109.8" font-family="Helvetica,Arial,sans-serif" font-size="14.00">1</text>
</g>
<!-- 0 -->
<g id="node7" class="node">
<title>0</title>
<ellipse fill="none" stroke="black" cx="258" cy="-79" rx="18" ry="18"/>
<text text-anchor="middle" x="258" y="-75.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">0</text>
</g>
<!-- 3&#45;&gt;0 -->
<g id="edge7" class="edge">
<title>3&#45;&gt;0</title>
<path fill="none" stroke="black" d="M196.31,-79C206.11,-79 218.58,-79 229.67,-79"/>
<polygon fill="black" stroke="black" points="229.74,-82.5 239.74,-79 229.74,-75.5 229.74,-82.5"/>
<text text-anchor="middle" x="218" y="-82.8" font-family="Helvetica,Arial,sans-serif" font-size="14.00">4</text>
</g>
<!-- 2&#45;&gt;0 -->
<g id="edge8" class="edge">
<title>2&#45;&gt;0</title>
<path fill="none" stroke="black" d="M193.31,-34.9C204.74,-42.82 220.99,-54.07 234.21,-63.22"/>
<polygon fill="black" stroke="black" points="232.57,-66.34 242.78,-69.16 236.55,-60.59 232.57,-66.34"/>
<text text-anchor="middle" x="218" y="-56.8" font-family="Helvetica,Arial,sans-serif" font-size="14.00">3</text>
</g>
<!-- 1&#45;&gt;0 -->
<g id="edge3" class="edge">
<g id="edge9" 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>
<path fill="none" stroke="black" d="M193.31,-123.1C204.74,-115.18 220.99,-103.93 234.21,-94.78"/>
<polygon fill="black" stroke="black" points="236.55,-97.41 242.78,-88.84 232.57,-91.66 236.55,-97.41"/>
<text text-anchor="middle" x="218" y="-110.8" font-family="Helvetica,Arial,sans-serif" font-size="14.00">2</text>
</g>
<!-- 6 -->
<g id="node5" class="node">
<title>6</title>
<ellipse fill="none" stroke="black" cx="18" cy="-45" rx="18" ry="18"/>
<text text-anchor="middle" x="18" y="-41.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">6</text>
</g>
<!-- 6&#45;&gt;4 -->
<g id="edge4" class="edge">
<title>6&#45;&gt;4</title>
<path fill="none" stroke="black" d="M35.16,-51.63C45.69,-55.95 59.65,-61.68 71.64,-66.59"/>
<polygon fill="black" stroke="black" points="70.55,-69.93 81.13,-70.49 73.2,-63.45 70.55,-69.93"/>
<text text-anchor="middle" x="58" y="-64.8" font-family="Helvetica,Arial,sans-serif" font-size="14.00">1</text>
</g>
<!-- 5 -->
<g id="node6" class="node">
<title>5</title>
<ellipse fill="none" stroke="black" cx="98" cy="-18" rx="18" ry="18"/>
<text text-anchor="middle" x="98" y="-14.3" font-family="Helvetica,Arial,sans-serif" font-size="14.00">5</text>
</g>
<!-- 6&#45;&gt;5 -->
<g id="edge5" class="edge">
<title>6&#45;&gt;5</title>
<path fill="none" stroke="black" d="M34.92,-38.29C40.86,-35.88 47.7,-33.21 54,-31 59.43,-29.1 65.3,-27.21 70.9,-25.49"/>
<polygon fill="black" stroke="black" points="71.98,-28.82 80.56,-22.61 69.97,-22.12 71.98,-28.82"/>
<text text-anchor="middle" x="58" y="-34.8" font-family="Helvetica,Arial,sans-serif" font-size="14.00">1</text>
</g>
<!-- 5&#45;&gt;2 -->
<g id="edge6" class="edge">
<title>5&#45;&gt;2</title>
<path fill="none" stroke="black" d="M114.92,-10.79C123.03,-8.01 133.04,-5.94 142,-8 145.71,-8.85 149.48,-10.15 153.1,-11.66"/>
<polygon fill="black" stroke="black" points="151.68,-14.86 162.22,-15.98 154.68,-8.54 151.68,-14.86"/>
<text text-anchor="middle" x="138" y="-11.8" font-family="Helvetica,Arial,sans-serif" font-size="14.00">1</text>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View file

@ -8,9 +8,21 @@
let () =
let xs = List.rev (enterAllChoices ()) in
let () = displayAllChoices xs in
let () = displayAllChoices (List.map (
fun x -> match x with
| (a,_,_) -> a
)
xs) in
();
let g = buildGraph xs in
let () = exportBase g "./outFileApp" in
let ys = enterChildren (getMaximumNodeId g) xs in
let gComplete = addChildren ys g in
let gFinal = main gComplete (getMaximumNodeId gComplete) 0 in
let () = exportBase gComplete "./outFileApp" in
()

View file

@ -2,17 +2,48 @@ open Graph
open Gfile
open Tools
let fst3 x = match x with
| (a,_,_) -> a
let thrd3 = function
| (_, _, a ) -> a
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
| (_,id,capa) :: xs -> inner (add_arc (new_node acc id) id 0 capa) xs
in
inner g xs
let getMaximumNodeId g =
n_fold g (fun x id -> max x id) 0
let thrd = function
| (_, _, a ) -> a
(*Adds all the choices of the children to the grap (i.e. create a node for each and then an edge from the
node toward the desired node(s). This function also completes the graph by adding a starting node*)
let addChildren xxs g =
(*the id of the start is the maximum id + the number of added nodes + 1 to get the next maximum id *)
let startId = (getMaximumNodeId g) + (List.length xxs) + 1 in
(*We create the node*)
let g2 = new_node g startId in
(*goes over all the activities of a children*)
let rec activitiesIterator childNode acc = function
| [] -> acc
| x :: xs -> activitiesIterator childNode (add_arc acc childNode x 1) xs
in
(*tool function to create the node for said children and create the edge from th start to this node*)
let addChildrenNode g a =
let g1 = (new_node g a) in
add_arc g1 startId a 1
in
(*goes over all the children of the list*)
let rec childrenIterator acc = function
| [] -> acc
| (a,b,c) :: xs -> childrenIterator (activitiesIterator a (addChildrenNode acc a) c) xs
in
childrenIterator g2 xxs

View file

@ -2,8 +2,13 @@ open Graph
open Gfile
open Tools
val buildGraph : (string * int) list -> int graph
val fst3 : ('a * 'b * 'c) -> 'a
val thrd3 : ('a * 'b * 'c) -> 'c
val buildGraph : (string * int * int) list -> int graph
val getMaximumNodeId : 'a graph -> int
val thrd : ('a * 'b * 'c) -> 'c
val addChildren : (id * string * int list) list -> int graph -> int graph

View file

@ -1,3 +1,5 @@
open AppTools
(* Prompts the user to enter all activities and stores them in a (id, name) list*)
let enterAllChoices () =
let rec inner xs i =
@ -6,10 +8,23 @@ let enterAllChoices () =
then
xs
else
inner ((str,i) :: xs) (i+1)
let inputs = List.filter (fun s -> s <> "") (String.split_on_char ' ' str) in
if (List.length inputs) = 2
then
try
let name = List.hd inputs in
let capa = int_of_string (List.nth inputs 1) in
inner ((name,i,capa) :: xs) (i+1)
with
| _ -> let () = (print_string "\nPlease enter a string followed by a number\n") in
(); inner xs i
else
let () = (print_string "\nPlease enter a string followed by a number\n") in
(); inner xs i
in
print_string "Enter the next possible choices for the children separated \
by new lines, hit enter to finish \n";
print_string "Enter the possible choices for the children separated \
by new lines and followed by their capacity, hit enter twice to finish \n";
inner [] 1
(* Displays all of the activities alongside their id*)
@ -19,12 +34,12 @@ let displayAllChoices xs =
| 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))
print_string (inner 1 "" 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*
Takes in input the number of the previously assigned nodes' maximum id
and the list of activities) *)
@ -37,22 +52,34 @@ let enterChildren idPrev listActivities =
then
xs
else
(*if str = "1"
if str = "HELP"
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)
let () = (print_string "\n=========\n"); displayAllChoices (List.map (fun x -> (fst3 x)) listActivities);
(print_string "=========\n") in () ;
inner xs i
else
let inputs = List.filter (fun s -> s <> "") (String.split_on_char ' ' str) in
try
let choices = List.sort_uniq (-) (List.map (fun x -> int_of_string x) (List.tl inputs)) in
if List.exists (fun x -> x > idPrev) choices
then
let () = (print_string "\n=========\n Please only enter digits that match activities\n");
(print_string "=========\n");
displayAllChoices (List.map (fun x -> (fst3 x)) listActivities); in () ;
inner xs i
else
inner ((i, (List.hd inputs), choices) :: xs) (i+1)
with
| _ -> (print_string "=========\n");
(print_string "Usage : name id1 id2 id3");
(print_string "\n=========\n");
inner xs i
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";
activities they are interested in. type \'HELP\' 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 *)

View file

@ -1,28 +1,7 @@
val enterAllChoices: unit -> (string * int) list
open Graph
val displayAllChoices: (string * int) list -> unit
val enterAllChoices: unit -> (string * int * int) list
(*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 displayAllChoices: string list -> unit
val enterChildren: int -> (string * int) list -> (int * string * int list) list
(*TODO val setCapcities : int graph -> int graph *)
val enterChildren: int -> (string * int * int) list -> (int * string * (int list)) list