module PrettyPrinter.GraphViz.Simulation where
open import Data.Nat
open import Data.Bool renaming (Bool to πΉ; _β_ to _βα΅_)
open import Data.List
open import Data.Product using (_Γ_; β-syntax; projβ; projβ) renaming (_,_ to β¨_,_β©)
open import Relation.Nullary.Decidable using (isYes)
open import Agda.Builtin.String
open import Text.Printf
open import Common.Utils using (magic-num)
open import Common.Types
open import CC.MultiStep
open import PrettyPrinter.GraphViz.MultiStep renaming (pprint to pprint-β )
print-sim-edges : List (β Γ β) β (last-n : β) β String
print-sim-edges [] last = ""
print-sim-edges (β¨ n , m β© β· rest) last =
let l_node = printf "left%u" n
r_node = printf "right%u" m in
primStringAppend
(if isYes (n β last)
then (printf " %s -> %s;\n" l_node r_node)
else (printf " %s -> %s; { rank=\"same\"; %s; %s; }\n" l_node r_node l_node r_node))
(print-sim-edges rest n)
print-sim-diagram : β {Mβ Mββ² Mβ Mββ² ΞΌβ ΞΌββ² ΞΌβ ΞΌββ²}
β Mβ β£ ΞΌβ β£ low ββ Mβ β£ ΞΌβ
β Mββ² β£ ΞΌββ² β£ low ββ Mββ² β£ ΞΌββ²
β List (β Γ β)
β String
print-sim-diagram Mββ Mβ Mββ²β Mββ² s =
printf
"digraph {
splines=line;
node[shape=plaintext];
subgraph left {
rankdir=\"TB\";
%s
}
subgraph right {
rankdir=\"TB\";
%s
}
edge[style=dotted, constraint=false, arrowhead=none, minlen=3];
%s
}\n" (pprint-β "left" Mββ Mβ) (pprint-β "right" Mββ²β Mββ²) (print-sim-edges s magic-num)