rs: Add pretty-print-state-graph.

This commit is contained in:
Sergiu Ivanov 2020-03-03 00:12:45 +01:00
parent a3967d8bf8
commit f22d42f98c

12
rs.rkt
View file

@ -26,13 +26,14 @@
[dds-build-n-step-state-graph (-> dynamics? (set/c state? #:kind 'dont-care) number? graph?)] [dds-build-n-step-state-graph (-> dynamics? (set/c state? #:kind 'dont-care) number? graph?)]
[dds-build-state-graph-annotated (-> dynamics? (set/c state? #:kind 'dont-care) graph?)] [dds-build-state-graph-annotated (-> dynamics? (set/c state? #:kind 'dont-care) graph?)]
[dds-build-n-step-state-graph-annotated (-> dynamics? (set/c state? #:kind 'dont-care) number? graph?)] [dds-build-n-step-state-graph-annotated (-> dynamics? (set/c state? #:kind 'dont-care) number? graph?)]
[build-interactive-process (-> reaction-system/c (listof (set/c species?)) graph?)]) [build-interactive-process (-> reaction-system/c (listof (set/c species?)) graph?)]
[pretty-print-state-graph (-> graph? graph?)])
;; Predicates ;; Predicates
(contract-out [species? (-> any/c boolean?)]) (contract-out [species? (-> any/c boolean?)])
;; Contracts ;; Contracts
(contract-out [reaction-system/c contract?]) (contract-out [reaction-system/c contract?])
;; Syntax ;; Syntax
unorg-rs org-rs read-ctx) unorg-rs org-rs read-ctx ppsg)
;;; ================= ;;; =================
;;; Basic definitions ;;; Basic definitions
@ -171,3 +172,10 @@
(define (build-interactive-process rs contexts) (define (build-interactive-process rs contexts)
(dds-build-state-graph-annotated (dynamics rs) (dds-build-state-graph-annotated (dynamics rs)
(set (state (set) contexts)))) (set (state (set) contexts))))
;;; Pretty prints the state graph of a reaction system.
(define (pretty-print-state-graph sgr)
(update-graph sgr #:e-func pretty-print-set-sets))
;;; A shortcut for pretty-print-state-graph.
(define-syntax-rule (ppsg sgr) (pretty-print-state-graph sgr))