72 lines
1.8 KiB
OCaml
72 lines
1.8 KiB
OCaml
open Graph
|
|
open Printf
|
|
open Gfile
|
|
|
|
let exportBase g path =
|
|
let str = e_fold
|
|
g
|
|
(fun x id1 id2 label -> x ^ "\n "
|
|
^ (string_of_int id1) ^ " -> "
|
|
^ (string_of_int id2) ^ " [label = \""
|
|
^ (string_of_int label) ^ "\"];" )
|
|
""
|
|
in
|
|
|
|
let startStr =
|
|
"
|
|
digraph finite_state_machine {\n
|
|
fontname=\"Helvetica,Arial,sans-serif\"\n
|
|
node [fontname=\"Helvetica,Arial,sans-serif\"]\n
|
|
edge [fontname=\"Helvetica,Arial,sans-serif\"]\n
|
|
rankdir=LR;\n
|
|
node [shape = circle];\n
|
|
"
|
|
in
|
|
|
|
let finishStr = "\n}" in
|
|
|
|
let totalStr = startStr ^ str ^ finishStr in
|
|
|
|
let ff = open_out path in
|
|
fprintf ff "%s%!" totalStr;
|
|
close_out ff;
|
|
()
|
|
|
|
|
|
|
|
let exportDifference gStart gEnd path =
|
|
let findUsedCapacity gEnd id1 id2 capaStart =
|
|
let newEdge = find_arc gEnd id1 id2 in
|
|
match newEdge with
|
|
| None -> capaStart
|
|
| Some a -> capaStart - a
|
|
in
|
|
let str = e_fold
|
|
gStart
|
|
(fun x id1 id2 label -> x ^ "\n "
|
|
^ (string_of_int id1) ^ " -> "
|
|
^ (string_of_int id2) ^ " [label = \""
|
|
^ string_of_int (findUsedCapacity gEnd id1 id2 label) ^ "/"
|
|
^ (string_of_int label) ^"\"];" )
|
|
""
|
|
in
|
|
|
|
let startStr =
|
|
"
|
|
digraph finite_state_machine {\n
|
|
fontname=\"Helvetica,Arial,sans-serif\"\n
|
|
node [fontname=\"Helvetica,Arial,sans-serif\"]\n
|
|
edge [fontname=\"Helvetica,Arial,sans-serif\"]\n
|
|
rankdir=LR;\n
|
|
node [shape = circle];\n
|
|
"
|
|
in
|
|
|
|
let finishStr = "\n}" in
|
|
|
|
let totalStr = startStr ^ str ^ finishStr in
|
|
|
|
let ff = open_out path in
|
|
fprintf ff "%s%!" totalStr;
|
|
close_out ff;
|
|
()
|