From e79fef91184c42073e85fe3eba647678faa3423d Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Fri, 23 Oct 2020 00:17:36 +0200 Subject: [PATCH] networks: Add build-tbn-state-graph and use it in example. --- example/example.org | 14 +++----------- networks.rkt | 10 +++++++++- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/example/example.org b/example/example.org index 6c45115..bf21db9 100644 --- a/example/example.org +++ b/example/example.org @@ -1042,11 +1042,7 @@ tab #+NAME: tbfs-nots-sg #+BEGIN_SRC racket :results silent drawer :var tbfs-nots=munch-sexp(tbfs-nots) -(dotit ((compose pretty-print-state-graph - build-full-01-state-graph - make-syn-dynamics - tbn->network - read-org-tbn) tbfs-nots)) +(dotit (build-tbn-state-graph (read-org-tbn tbfs-nots))) #+END_SRC #+BEGIN_SRC dot :file dots/examplew206DH.svg :results raw drawer :cmd sfdp :noweb yes @@ -1069,11 +1065,7 @@ tab #+NAME: sbn-figure2-sg #+BEGIN_SRC racket :results silent drawer :var sbn-figure2=munch-sexp(sbn-figure2) -(dotit ((compose pretty-print-state-graph - build-full-01-state-graph - make-syn-dynamics - tbn->network - read-org-sbn) sbn-figure2)) +(dotit (build-tbn-state-graph (read-org-sbn sbn-figure2))) #+END_SRC #+BEGIN_SRC dot :file dots/sbn-figure2-sg.svg :results raw drawer :cmd sfdp :noweb yes @@ -1082,7 +1074,7 @@ tab #+RESULTS: :results: - [[file:dots/sbn-figure2-sg.svg]] + [[file:dots/sbn-figure2-sg.svg]] :end: * Reaction systems diff --git a/networks.rkt b/networks.rkt index b3243dd..6aea0cc 100644 --- a/networks.rkt +++ b/networks.rkt @@ -116,7 +116,8 @@ tbn?)] [read-org-sbn (->* (string?) (#:headers boolean? #:func-names boolean?) - tbn?)]) + tbn?)] + [build-tbn-state-graph (-> tbn? graph?)]) ;; Predicates (contract-out [variable? (-> any/c boolean?)] [state? (-> any/c boolean?)] @@ -1466,3 +1467,10 @@ (tbf/state '#hash((x0 . -1) (x1 . 0)) 0) 'x1 (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))