From 32b2e41634fbdd42e5777d1d225d6a32b290934b Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Fri, 8 May 2020 23:33:43 +0200 Subject: [PATCH] example: Explain how to read back and explore networks from Org tables. --- example/dots/exampleHc023j.svg | 175 +++++++++++++++++++++++++++++++++ example/dots/examplePIN5ac.svg | 45 +++++++++ example/example.org | 76 ++++++++++++++ 3 files changed, 296 insertions(+) create mode 100644 example/dots/exampleHc023j.svg create mode 100644 example/dots/examplePIN5ac.svg diff --git a/example/dots/exampleHc023j.svg b/example/dots/exampleHc023j.svg new file mode 100644 index 0000000..05d4020 --- /dev/null +++ b/example/dots/exampleHc023j.svg @@ -0,0 +1,175 @@ + + + + + + +G + + + +node0 + +a:#f b:1 c:cold + + + +node0->node0 + +{a} + + + +node5 + +a:#f b:2 c:cold + + + +node0->node5 + +{b} + + + +node7 + +a:#f b:1 c:hot + + + +node0->node7 + +{c} + + + +node1 + +a:#t b:2 c:cold + + + +node1->node1 + +{b} + + + +node1->node5 + +{a} + + + +node6 + +a:#t b:2 c:hot + + + +node1->node6 + +{c} + + + +node2 + +a:#t b:1 c:cold + + + +node2->node0 + + +{a} + + + +node2->node1 + + +{b} + + + +node2->node2 + +{c} + + + +node3 + +a:#t b:1 c:hot + + + +node3->node2 + + +{c} + + + +node3->node3 + +{b}{a} + + + +node4 + +a:#f b:2 c:hot + + + +node4->node4 + +{c}{b} + + + +node4->node6 + + +{a} + + + +node5->node5 + +{c} + + + +node6->node3 + + +{b} + + + +node6->node6 + +{a} + + + +node7->node4 + + +{b} + + + +node7->node7 + +{a} + + + diff --git a/example/dots/examplePIN5ac.svg b/example/dots/examplePIN5ac.svg new file mode 100644 index 0000000..7b10d04 --- /dev/null +++ b/example/dots/examplePIN5ac.svg @@ -0,0 +1,45 @@ + + + + + + +G + + + +node0 + +c + + + +node2 + +a + + + +node0->node2 + + ++ + + + +node1 + +b + + + +node1->node2 + + ++ + + + diff --git a/example/example.org b/example/example.org index 58c0ccd..6cb6761 100644 --- a/example/example.org +++ b/example/example.org @@ -576,6 +576,82 @@ tab | #t | 2 | hot | #t | 1 | cold | :END: + Let's snapshot this random network and give it a name. + #+NAME: rnd-network + | a | b | c | f-a | f-b | f-c | + | #f | 1 | cold | #f | 2 | hot | + | #f | 1 | hot | #f | 2 | cold | + | #f | 2 | cold | #t | 1 | cold | + | #f | 2 | hot | #t | 2 | hot | + | #t | 1 | cold | #f | 2 | cold | + | #t | 1 | hot | #t | 1 | cold | + | #t | 2 | cold | #f | 2 | hot | + | #t | 2 | hot | #t | 1 | cold | + + Here's how we can read back this table as a Boolean network: + #+HEADER: :var rnd-network=munch-sexp(rnd-network) + #+BEGIN_SRC racket :results output drawer +(string->any rnd-network) + #+END_SRC + + #+RESULTS: + :RESULTS: + '(("a" "b" "c" "f-a" "f-b" "f-c") ("#f" 1 "cold" "#f" 2 "hot") ("#f" 1 "hot" "#f" 2 "cold") ("#f" 2 "cold" "#t" 1 "cold") ("#f" 2 "hot" "#t" 2 "hot") ("#t" 1 "cold" "#f" 2 "cold") ("#t" 1 "hot" "#t" 1 "cold") ("#t" 2 "cold" "#f" 2 "hot") ("#t" 2 "hot" "#t" 1 "cold")) + :END: + + You can use =table->network= to convert a table such as [[rnd-network][rnd-network]] + to a network. + #+HEADER: :var rnd-network=munch-sexp(rnd-network) + #+BEGIN_SRC racket :results output drawer +(table->network (unorg rnd-network)) + #+END_SRC + + #+RESULTS: + :RESULTS: + '#hash((a . #) (b . #) (c . #)) + :END: + + Here's the state graph of [[rnd-network][rnd-network]]. + #+NAME: rnd-network-sg + #+HEADER: :var rnd-network=munch-sexp(rnd-network) + #+HEADER: :var simple-domains=munch-sexp(simple-domains) + #+BEGIN_SRC racket :results silent drawer +(define n (table->network (unorg rnd-network))) +(define rnd-asyn (make-asyn-dynamics n)) +(define states (list->set (build-all-states (unorgv simple-domains)))) +(dotit (pretty-print-state-graph (dds-build-state-graph-annotated rnd-asyn states))) + #+END_SRC + + #+BEGIN_SRC dot :file dots/exampleHc023j.svg :results raw drawer :cmd sfdp :noweb yes +<> + #+END_SRC + + #+RESULTS: + :RESULTS: + [[file:dots/exampleHc023j.svg]] + :END: + + Here's the signed interaction graph of [[rnd-network][rnd-network]]. + #+NAME: rnd-network-ig + #+HEADER: :var rnd-network=munch-sexp(rnd-network) + #+HEADER: :var simple-domains=munch-sexp(simple-domains) + #+BEGIN_SRC racket :results silent drawer +(define n (table->network (unorg rnd-network))) +(dotit (build-signed-interaction-graph n (unorgv simple-domains))) + #+END_SRC + + #+BEGIN_SRC dot :file dots/examplePIN5ac.svg :results raw drawer :cmd sfdp :noweb yes +<> + #+END_SRC + + #+RESULTS: + :RESULTS: + [[file:dots/examplePIN5ac.svg]] + :END: + + Note that =build-signed-interaction-graph= only includes the + and + the - arcs in the graph, as it does not have access to the symbolic + description of the function. * Reaction systems :PROPERTIES: