networks: Add build-tbn-state-graph and use it in example.

This commit is contained in:
Sergiu Ivanov 2020-10-23 00:17:36 +02:00
parent 485b859f34
commit e79fef9118
2 changed files with 12 additions and 12 deletions

View file

@ -1042,11 +1042,7 @@ tab
#+NAME: tbfs-nots-sg #+NAME: tbfs-nots-sg
#+BEGIN_SRC racket :results silent drawer :var tbfs-nots=munch-sexp(tbfs-nots) #+BEGIN_SRC racket :results silent drawer :var tbfs-nots=munch-sexp(tbfs-nots)
(dotit ((compose pretty-print-state-graph (dotit (build-tbn-state-graph (read-org-tbn tbfs-nots)))
build-full-01-state-graph
make-syn-dynamics
tbn->network
read-org-tbn) tbfs-nots))
#+END_SRC #+END_SRC
#+BEGIN_SRC dot :file dots/examplew206DH.svg :results raw drawer :cmd sfdp :noweb yes #+BEGIN_SRC dot :file dots/examplew206DH.svg :results raw drawer :cmd sfdp :noweb yes
@ -1069,11 +1065,7 @@ tab
#+NAME: sbn-figure2-sg #+NAME: sbn-figure2-sg
#+BEGIN_SRC racket :results silent drawer :var sbn-figure2=munch-sexp(sbn-figure2) #+BEGIN_SRC racket :results silent drawer :var sbn-figure2=munch-sexp(sbn-figure2)
(dotit ((compose pretty-print-state-graph (dotit (build-tbn-state-graph (read-org-sbn sbn-figure2)))
build-full-01-state-graph
make-syn-dynamics
tbn->network
read-org-sbn) sbn-figure2))
#+END_SRC #+END_SRC
#+BEGIN_SRC dot :file dots/sbn-figure2-sg.svg :results raw drawer :cmd sfdp :noweb yes #+BEGIN_SRC dot :file dots/sbn-figure2-sg.svg :results raw drawer :cmd sfdp :noweb yes

View file

@ -116,7 +116,8 @@
tbn?)] tbn?)]
[read-org-sbn (->* (string?) [read-org-sbn (->* (string?)
(#:headers boolean? #:func-names boolean?) (#:headers boolean? #:func-names boolean?)
tbn?)]) tbn?)]
[build-tbn-state-graph (-> tbn? graph?)])
;; Predicates ;; Predicates
(contract-out [variable? (-> any/c boolean?)] (contract-out [variable? (-> any/c boolean?)]
[state? (-> any/c boolean?)] [state? (-> any/c boolean?)]
@ -1466,3 +1467,10 @@
(tbf/state '#hash((x0 . -1) (x1 . 0)) 0) (tbf/state '#hash((x0 . -1) (x1 . 0)) 0)
'x1 'x1
(tbf/state '#hash((x0 . 0) (x1 . -1)) 0))))) (tbf/state '#hash((x0 . 0) (x1 . -1)) 0)))))
;;; A shortcut for building the state graphs of TBN.
(define build-tbn-state-graph
(compose pretty-print-state-graph
build-full-01-state-graph
make-syn-dynamics
tbn->network))