example: Add an example on printing annotated state graphs for networks.

This commit is contained in:
Sergiu Ivanov 2020-03-01 15:22:11 +01:00
parent a3f5d4d2ba
commit 02d564a374
3 changed files with 263 additions and 57 deletions

View File

@ -4,91 +4,91 @@
<!-- Generated by graphviz version 2.43.0 (0)
-->
<!-- Title: G Pages: 1 -->
<svg width="1119pt" height="349pt"
viewBox="0.00 0.00 1119.41 349.34" 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 345.34)">
<svg width="1115pt" height="353pt"
viewBox="0.00 0.00 1115.45 352.61" 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 348.61)">
<title>G</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-345.34 1115.41,-345.34 1115.41,4 -4,4"/>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-348.61 1111.45,-348.61 1111.45,4 -4,4"/>
<!-- node0 -->
<g id="node1" class="node">
<title>node0</title>
<ellipse fill="none" stroke="black" cx="1052.26" cy="-171.19" rx="59.29" ry="18"/>
<text text-anchor="middle" x="1052.26" y="-167.49" font-family="Times-Roman" font-size="14.00">a:0 c:0 b:0</text>
</g>
<!-- node1 -->
<g id="node2" class="node">
<title>node1</title>
<ellipse fill="none" stroke="black" cx="557.25" cy="-323.34" rx="59.29" ry="18"/>
<text text-anchor="middle" x="557.25" y="-319.64" font-family="Times-Roman" font-size="14.00">a:1 c:0 b:1</text>
<ellipse fill="none" stroke="black" cx="779.24" cy="-173.26" rx="59.29" ry="18"/>
<text text-anchor="middle" x="779.24" y="-169.56" font-family="Times-Roman" font-size="14.00">a:0 b:1 c:0</text>
</g>
<!-- node2 -->
<g id="node3" class="node">
<title>node2</title>
<ellipse fill="none" stroke="black" cx="59.14" cy="-171.21" rx="59.29" ry="18"/>
<text text-anchor="middle" x="59.14" y="-167.51" font-family="Times-Roman" font-size="14.00">a:1 c:1 b:0</text>
<ellipse fill="none" stroke="black" cx="554.95" cy="-18" rx="59.29" ry="18"/>
<text text-anchor="middle" x="554.95" y="-14.3" font-family="Times-Roman" font-size="14.00">a:0 b:1 c:1</text>
</g>
<!-- node3 -->
<g id="node4" class="node">
<title>node3</title>
<ellipse fill="none" stroke="black" cx="557.62" cy="-18" rx="59.29" ry="18"/>
<text text-anchor="middle" x="557.62" y="-14.3" font-family="Times-Roman" font-size="14.00">a:0 c:1 b:1</text>
</g>
<!-- node3&#45;&gt;node3 -->
<!-- node0&#45;&gt;node2 -->
<g id="edge1" class="edge">
<title>node3&#45;&gt;node3</title>
<path fill="none" stroke="black" d="M612.75,-24.6C625.44,-24.03 634.77,-21.83 634.77,-18 634.77,-14.17 625.44,-11.97 612.75,-11.4"/>
<title>node0&#45;&gt;node2</title>
<path fill="none" stroke="black" d="M755.24,-156.64C712.07,-126.76 621.82,-64.29 578.78,-34.5"/>
</g>
<!-- node4 -->
<g id="node5" class="node">
<title>node4</title>
<ellipse fill="none" stroke="black" cx="784.6" cy="-170.9" rx="59.29" ry="18"/>
<text text-anchor="middle" x="784.6" y="-167.2" font-family="Times-Roman" font-size="14.00">a:0 c:0 b:1</text>
<ellipse fill="none" stroke="black" cx="553.27" cy="-326.61" rx="59.29" ry="18"/>
<text text-anchor="middle" x="553.27" y="-322.91" font-family="Times-Roman" font-size="14.00">a:1 b:1 c:0</text>
</g>
<!-- node3&#45;&gt;node4 -->
<g id="edge2" class="edge">
<title>node3&#45;&gt;node4</title>
<path fill="none" stroke="black" d="M582.35,-34.65C626.01,-64.07 716.27,-124.87 759.91,-154.27"/>
<!-- node0&#45;&gt;node4 -->
<g id="edge5" class="edge">
<title>node0&#45;&gt;node4</title>
<path fill="none" stroke="black" d="M754.63,-189.96C713.69,-217.75 631.58,-273.46 585.88,-304.48"/>
<polygon fill="black" stroke="black" points="583.82,-301.65 577.51,-310.16 587.75,-307.44 583.82,-301.65"/>
</g>
<!-- node5 -->
<g id="node6" class="node">
<title>node5</title>
<ellipse fill="none" stroke="black" cx="335.15" cy="-170.6" rx="59.29" ry="18"/>
<text text-anchor="middle" x="335.15" y="-166.9" font-family="Times-Roman" font-size="14.00">a:1 c:1 b:1</text>
<ellipse fill="none" stroke="black" cx="1048.31" cy="-174.03" rx="59.29" ry="18"/>
<text text-anchor="middle" x="1048.31" y="-170.33" font-family="Times-Roman" font-size="14.00">a:0 b:0 c:0</text>
</g>
<!-- node3&#45;&gt;node5 -->
<!-- node0&#45;&gt;node5 -->
<g id="edge4" class="edge">
<title>node3&#45;&gt;node5</title>
<path fill="none" stroke="black" d="M533.39,-34.62C493.19,-62.2 412.67,-117.42 367.6,-148.34"/>
<polygon fill="black" stroke="black" points="365.62,-145.45 359.35,-154 369.58,-151.23 365.62,-145.45"/>
<title>node0&#45;&gt;node5</title>
<path fill="none" stroke="black" d="M838.62,-173.43C880.03,-173.55 935.42,-173.71 978.87,-173.83"/>
<polygon fill="black" stroke="black" points="979.07,-177.33 989.08,-173.86 979.09,-170.33 979.07,-177.33"/>
</g>
<!-- node4&#45;&gt;node0 -->
<g id="edge5" class="edge">
<title>node4&#45;&gt;node0</title>
<path fill="none" stroke="black" d="M844.01,-170.97C885.07,-171.01 939.84,-171.07 982.91,-171.12"/>
<polygon fill="black" stroke="black" points="983.02,-174.62 993.03,-171.13 983.03,-167.62 983.02,-174.62"/>
<!-- node1 -->
<g id="node2" class="node">
<title>node1</title>
<ellipse fill="none" stroke="black" cx="59.14" cy="-173.46" rx="59.29" ry="18"/>
<text text-anchor="middle" x="59.14" y="-169.76" font-family="Times-Roman" font-size="14.00">a:1 b:0 c:1</text>
</g>
<!-- node4&#45;&gt;node1 -->
<!-- node2&#45;&gt;node2 -->
<g id="edge2" class="edge">
<title>node2&#45;&gt;node2</title>
<path fill="none" stroke="black" d="M610.08,-24.6C622.77,-24.03 632.09,-21.83 632.09,-18 632.09,-14.17 622.77,-11.97 610.08,-11.4"/>
</g>
<!-- node3 -->
<g id="node4" class="node">
<title>node3</title>
<ellipse fill="none" stroke="black" cx="328.27" cy="-173.36" rx="59.29" ry="18"/>
<text text-anchor="middle" x="328.27" y="-169.66" font-family="Times-Roman" font-size="14.00">a:1 b:1 c:1</text>
</g>
<!-- node2&#45;&gt;node3 -->
<g id="edge6" class="edge">
<title>node4&#45;&gt;node1</title>
<path fill="none" stroke="black" d="M759.84,-187.51C718.76,-215.05 636.47,-270.22 590.42,-301.1"/>
<polygon fill="black" stroke="black" points="588.34,-298.28 581.99,-306.75 592.24,-304.09 588.34,-298.28"/>
<title>node2&#45;&gt;node3</title>
<path fill="none" stroke="black" d="M530.69,-34.63C489.7,-62.72 406.73,-119.59 360.76,-151.1"/>
<polygon fill="black" stroke="black" points="358.63,-148.32 352.36,-156.86 362.59,-154.09 358.63,-148.32"/>
</g>
<!-- node5&#45;&gt;node1 -->
<g id="edge8" class="edge">
<title>node5&#45;&gt;node1</title>
<path fill="none" stroke="black" d="M359.34,-187.23C399.39,-214.78 479.53,-269.88 524.57,-300.86"/>
<polygon fill="black" stroke="black" points="522.87,-303.94 533.09,-306.72 526.84,-298.17 522.87,-303.94"/>
</g>
<!-- node5&#45;&gt;node2 -->
<!-- node3&#45;&gt;node1 -->
<g id="edge7" class="edge">
<title>node5&#45;&gt;node2</title>
<path fill="none" stroke="black" d="M275.94,-170.73C232.79,-170.82 174.19,-170.96 128.79,-171.06"/>
<polygon fill="black" stroke="black" points="128.72,-167.56 118.73,-171.08 128.74,-174.56 128.72,-167.56"/>
<title>node3&#45;&gt;node1</title>
<path fill="none" stroke="black" d="M268.88,-173.38C227.46,-173.4 172.06,-173.42 128.6,-173.43"/>
<polygon fill="black" stroke="black" points="128.39,-169.93 118.39,-173.44 128.39,-176.93 128.39,-169.93"/>
</g>
<!-- node5&#45;&gt;node5 -->
<!-- node3&#45;&gt;node3 -->
<g id="edge3" class="edge">
<title>node5&#45;&gt;node5</title>
<path fill="none" stroke="black" d="M390.28,-177.2C402.97,-176.63 412.29,-174.43 412.29,-170.6 412.29,-166.76 402.97,-164.56 390.28,-163.99"/>
<title>node3&#45;&gt;node3</title>
<path fill="none" stroke="black" d="M383.4,-179.97C396.1,-179.4 405.42,-177.2 405.42,-173.36 405.42,-169.53 396.1,-167.33 383.4,-166.76"/>
</g>
<!-- node3&#45;&gt;node4 -->
<g id="edge8" class="edge">
<title>node3&#45;&gt;node4</title>
<path fill="none" stroke="black" d="M352.78,-190.06C393.55,-217.82 475.3,-273.5 520.81,-304.5"/>
<polygon fill="black" stroke="black" points="518.9,-307.43 529.14,-310.17 522.84,-301.65 518.9,-307.43"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,183 @@
<?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.43.0 (0)
-->
<!-- Title: G Pages: 1 -->
<svg width="843pt" height="558pt"
viewBox="0.00 0.00 843.47 557.73" 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 553.73)">
<title>G</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-553.73 839.47,-553.73 839.47,4 -4,4"/>
<!-- node0 -->
<g id="node1" class="node">
<title>node0</title>
<ellipse fill="none" stroke="black" cx="59.14" cy="-273.69" rx="59.29" ry="18"/>
<text text-anchor="middle" x="59.14" y="-269.99" font-family="Times-Roman" font-size="14.00">a:0 b:0 c:1</text>
</g>
<!-- node0&#45;&gt;node0 -->
<g id="edge1" class="edge">
<title>node0&#45;&gt;node0</title>
<path fill="none" stroke="black" d="M114.27,-280.29C126.97,-279.72 136.29,-277.52 136.29,-273.69 136.29,-269.86 126.97,-267.66 114.27,-267.09"/>
<text text-anchor="middle" x="140.79" y="-269.99" font-family="Times-Roman" font-size="14.00">a</text>
</g>
<!-- node2 -->
<g id="node3" class="node">
<title>node2</title>
<ellipse fill="none" stroke="black" cx="261.01" cy="-530.99" rx="59.29" ry="18"/>
<text text-anchor="middle" x="261.01" y="-527.29" font-family="Times-Roman" font-size="14.00">a:0 b:1 c:1</text>
</g>
<!-- node0&#45;&gt;node2 -->
<g id="edge12" class="edge">
<title>node0&#45;&gt;node2</title>
<path fill="none" stroke="black" d="M73.02,-291.37C107.95,-335.9 199.66,-452.79 240.68,-505.07"/>
<polygon fill="black" stroke="black" points="238.11,-507.47 247.04,-513.18 243.62,-503.15 238.11,-507.47"/>
<text text-anchor="middle" x="151.85" y="-402.02" font-family="Times-Roman" font-size="14.00">b</text>
</g>
<!-- node4 -->
<g id="node5" class="node">
<title>node4</title>
<ellipse fill="none" stroke="black" cx="263.53" cy="-18" rx="59.29" ry="18"/>
<text text-anchor="middle" x="263.53" y="-14.3" font-family="Times-Roman" font-size="14.00">a:0 b:0 c:0</text>
</g>
<!-- node0&#45;&gt;node4 -->
<g id="edge2" class="edge">
<title>node0&#45;&gt;node4</title>
<path fill="none" stroke="black" d="M73.19,-256.11C110.53,-209.4 211.93,-82.55 249.38,-35.7"/>
<text text-anchor="middle" x="157.29" y="-149.71" font-family="Times-Roman" font-size="14.00">c</text>
</g>
<!-- node1 -->
<g id="node2" class="node">
<title>node1</title>
<ellipse fill="none" stroke="black" cx="318.41" cy="-273.82" rx="59.29" ry="18"/>
<text text-anchor="middle" x="318.41" y="-270.12" font-family="Times-Roman" font-size="14.00">a:1 b:0 c:1</text>
</g>
<!-- node1&#45;&gt;node0 -->
<g id="edge13" class="edge">
<title>node1&#45;&gt;node0</title>
<path fill="none" stroke="black" d="M259.25,-273.79C220.4,-273.77 169.41,-273.74 128.63,-273.72"/>
<polygon fill="black" stroke="black" points="128.5,-270.22 118.49,-273.72 128.49,-277.22 128.5,-270.22"/>
<text text-anchor="middle" x="189.44" y="-277.56" font-family="Times-Roman" font-size="14.00">a</text>
</g>
<!-- node1&#45;&gt;node1 -->
<g id="edge4" class="edge">
<title>node1&#45;&gt;node1</title>
<path fill="none" stroke="black" d="M373.53,-280.42C386.23,-279.85 395.55,-277.65 395.55,-273.82 395.55,-269.99 386.23,-267.79 373.53,-267.22"/>
<text text-anchor="middle" x="400.55" y="-270.12" font-family="Times-Roman" font-size="14.00">b</text>
</g>
<!-- node7 -->
<g id="node8" class="node">
<title>node7</title>
<ellipse fill="none" stroke="black" cx="547.93" cy="-18.89" rx="59.29" ry="18"/>
<text text-anchor="middle" x="547.93" y="-15.19" font-family="Times-Roman" font-size="14.00">a:1 b:0 c:0</text>
</g>
<!-- node1&#45;&gt;node7 -->
<g id="edge3" class="edge">
<title>node1&#45;&gt;node7</title>
<path fill="none" stroke="black" d="M334.18,-256.3C376.11,-209.73 489.99,-83.25 532.05,-36.54"/>
<text text-anchor="middle" x="429.12" y="-150.22" font-family="Times-Roman" font-size="14.00">c</text>
</g>
<!-- node2&#45;&gt;node2 -->
<g id="edge6" class="edge">
<title>node2&#45;&gt;node2</title>
<path fill="none" stroke="black" d="M316.14,-537.59C328.83,-537.02 338.16,-534.82 338.16,-530.99 338.16,-527.15 328.83,-524.95 316.14,-524.38"/>
<text text-anchor="middle" x="343.16" y="-527.29" font-family="Times-Roman" font-size="14.00">b</text>
</g>
<!-- node5 -->
<g id="node6" class="node">
<title>node5</title>
<ellipse fill="none" stroke="black" cx="490.25" cy="-275.8" rx="59.29" ry="18"/>
<text text-anchor="middle" x="490.25" y="-272.1" font-family="Times-Roman" font-size="14.00">a:0 b:1 c:0</text>
</g>
<!-- node2&#45;&gt;node5 -->
<g id="edge5" class="edge">
<title>node2&#45;&gt;node5</title>
<path fill="none" stroke="black" d="M276.77,-513.45C318.65,-466.83 432.38,-340.22 474.38,-293.47"/>
<text text-anchor="middle" x="371.57" y="-407.26" font-family="Times-Roman" font-size="14.00">c</text>
</g>
<!-- node6 -->
<g id="node7" class="node">
<title>node6</title>
<ellipse fill="none" stroke="black" cx="545.29" cy="-531.73" rx="59.29" ry="18"/>
<text text-anchor="middle" x="545.29" y="-528.03" font-family="Times-Roman" font-size="14.00">a:1 b:1 c:1</text>
</g>
<!-- node2&#45;&gt;node6 -->
<g id="edge14" class="edge">
<title>node2&#45;&gt;node6</title>
<path fill="none" stroke="black" d="M320.26,-531.14C365.59,-531.26 428.21,-531.42 475.88,-531.55"/>
<polygon fill="black" stroke="black" points="476.11,-535.05 486.12,-531.57 476.13,-528.05 476.11,-535.05"/>
<text text-anchor="middle" x="393.57" y="-535.14" font-family="Times-Roman" font-size="14.00">a</text>
</g>
<!-- node3 -->
<g id="node4" class="node">
<title>node3</title>
<ellipse fill="none" stroke="black" cx="749.32" cy="-276.35" rx="59.29" ry="18"/>
<text text-anchor="middle" x="749.32" y="-272.65" font-family="Times-Roman" font-size="14.00">a:1 b:1 c:0</text>
</g>
<!-- node3&#45;&gt;node3 -->
<g id="edge8" class="edge">
<title>node3&#45;&gt;node3</title>
<path fill="none" stroke="black" d="M804.45,-282.95C817.15,-282.38 826.47,-280.18 826.47,-276.35 826.47,-272.52 817.15,-270.32 804.45,-269.75"/>
<text text-anchor="middle" x="830.97" y="-272.65" font-family="Times-Roman" font-size="14.00">a</text>
</g>
<!-- node3&#45;&gt;node6 -->
<g id="edge7" class="edge">
<title>node3&#45;&gt;node6</title>
<path fill="none" stroke="black" d="M735.3,-293.9C698.03,-340.56 596.8,-467.26 559.42,-514.05"/>
<text text-anchor="middle" x="643.36" y="-407.78" font-family="Times-Roman" font-size="14.00">c</text>
</g>
<!-- node3&#45;&gt;node7 -->
<g id="edge15" class="edge">
<title>node3&#45;&gt;node7</title>
<path fill="none" stroke="black" d="M735.48,-258.66C700.63,-214.1 609.14,-97.14 568.22,-44.83"/>
<polygon fill="black" stroke="black" points="570.79,-42.43 561.87,-36.71 565.28,-46.75 570.79,-42.43"/>
<text text-anchor="middle" x="646.85" y="-155.54" font-family="Times-Roman" font-size="14.00">b</text>
</g>
<!-- node4&#45;&gt;node4 -->
<g id="edge9" class="edge">
<title>node4&#45;&gt;node4</title>
<path fill="none" stroke="black" d="M318.66,-24.6C331.35,-24.03 340.67,-21.83 340.67,-18 340.67,-14.17 331.35,-11.97 318.66,-11.4"/>
<text text-anchor="middle" x="345.67" y="-14.3" font-family="Times-Roman" font-size="14.00">b</text>
</g>
<!-- node5&#45;&gt;node3 -->
<g id="edge17" class="edge">
<title>node5&#45;&gt;node3</title>
<path fill="none" stroke="black" d="M549.68,-275.93C588.52,-276.01 639.39,-276.12 680.06,-276.2"/>
<polygon fill="black" stroke="black" points="680.16,-279.7 690.16,-276.23 680.17,-272.7 680.16,-279.7"/>
<text text-anchor="middle" x="610.37" y="-279.87" font-family="Times-Roman" font-size="14.00">a</text>
</g>
<!-- node5&#45;&gt;node4 -->
<g id="edge16" class="edge">
<title>node5&#45;&gt;node4</title>
<path fill="none" stroke="black" d="M474.66,-258.08C435.25,-213.27 331.5,-95.3 285.75,-43.27"/>
<polygon fill="black" stroke="black" points="288.15,-40.7 278.92,-35.5 282.9,-45.32 288.15,-40.7"/>
<text text-anchor="middle" x="375.21" y="-154.47" font-family="Times-Roman" font-size="14.00">b</text>
</g>
<!-- node6&#45;&gt;node1 -->
<g id="edge18" class="edge">
<title>node6&#45;&gt;node1</title>
<path fill="none" stroke="black" d="M529.7,-514C490.26,-469.17 386.43,-351.15 340.64,-299.1"/>
<polygon fill="black" stroke="black" points="343.04,-296.53 333.81,-291.33 337.79,-301.15 343.04,-296.53"/>
<text text-anchor="middle" x="430.17" y="-410.35" font-family="Times-Roman" font-size="14.00">b</text>
</g>
<!-- node6&#45;&gt;node6 -->
<g id="edge10" class="edge">
<title>node6&#45;&gt;node6</title>
<path fill="none" stroke="black" d="M600.42,-538.33C613.11,-537.76 622.44,-535.56 622.44,-531.73 622.44,-527.9 613.11,-525.7 600.42,-525.13"/>
<text text-anchor="middle" x="626.94" y="-528.03" font-family="Times-Roman" font-size="14.00">a</text>
</g>
<!-- node7&#45;&gt;node4 -->
<g id="edge19" class="edge">
<title>node7&#45;&gt;node4</title>
<path fill="none" stroke="black" d="M488.66,-18.71C443.31,-18.57 380.67,-18.37 332.97,-18.22"/>
<polygon fill="black" stroke="black" points="332.74,-14.72 322.73,-18.19 332.71,-21.72 332.74,-14.72"/>
<text text-anchor="middle" x="406.31" y="-22.26" font-family="Times-Roman" font-size="14.00">a</text>
</g>
<!-- node7&#45;&gt;node7 -->
<g id="edge11" class="edge">
<title>node7&#45;&gt;node7</title>
<path fill="none" stroke="black" d="M603.06,-25.5C615.76,-24.93 625.08,-22.73 625.08,-18.89 625.08,-15.06 615.76,-12.86 603.06,-12.29"/>
<text text-anchor="middle" x="630.08" y="-15.19" font-family="Times-Roman" font-size="14.00">b</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -426,6 +426,29 @@ tab
[[file:dots/examplecHA6gL.svg]]
:END:
Here is the complete state graph with edges annotated with the
modality leading to the update.
#+NAME: simple-bn-sg-bool-ann
#+BEGIN_SRC racket :results silent :var simple-bn=munch-table(simple-bn)
(let* ([bn (nn (unorg simple-bn))]
[bn-asyn (make-asyn-dynamics bn)])
(dotit (ppsgb (build-full-boolean-state-graph-annotated bn-asyn))))
#+END_SRC
#+BEGIN_SRC dot :file dots/examplei4we6j.svg :results raw drawer :cmd sfdp :noweb yes
<<simple-bn-sg-bool-ann()>>
#+END_SRC
#+RESULTS:
:RESULTS:
[[file:dots/examplei4we6j.svg]]
:END:
* Roadmap
- [ ] fix the pretty printing of labelled graphs
- [ ] commend fallback-dds-build-state-graph-edges
- [ ] check what happens if two different modalities should be
attached to the same edge
* Local Variables :noexport:
# Local Variables: