rs: Add pretty-print-reduced-state-graph.

This commit is contained in:
Sergiu Ivanov 2020-11-11 00:36:49 +01:00
parent ce0d5023bf
commit 3b8ce5eb84
1 changed files with 15 additions and 0 deletions

15
rs.rkt
View File

@ -29,6 +29,7 @@
[dds-build-n-step-state-graph-annotated (-> dynamics? (set/c state? #:kind 'dont-care) number? graph?)]
[build-interactive-process-graph (-> reaction-system/c (listof (set/c species?)) graph?)]
[build-reduced-state-graph (-> reaction-system/c (listof (set/c species?)) graph?)]
[pretty-print-reduced-state-graph (-> graph? graph?)]
[build-interactive-process (-> reaction-system/c (listof (set/c species?)) (listof (list/c (set/c species?) (set/c species?))))]
[pretty-print-state-graph (-> graph? graph?)])
;; Predicates
@ -229,6 +230,20 @@
(check-equal? (graphviz (build-reduced-state-graph rs ctx))
"digraph G {\n\tnode0 [label=\"(set)\\n\"];\n\tnode1 [label=\"(set 'y 'z)\\n\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode0 -> node0 [label=\"#<set: #<set:>>\"];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node1 [label=\"#<set: #<set: a b>>\"];\n\t\tnode1 -> node0 [label=\"#<set: #<set:>>\"];\n\t}\n}\n")))
(define (pretty-print-reduced-state-graph sgr)
(update-graph sgr
#:v-func (λ (st) (~a "{" (pretty-print-set st) "}"))
#:e-func pretty-print-set-sets))
(module+ test
(test-case "pretty-print-reduced-graph"
(define rs (hash 'a (reaction (set 'x) (set 'y) (set 'z))
'b (reaction (set 'x) (set) (set 'y))))
(define ctx (list (set 'x) (set 'y) (set 'z) (set) (set 'z)))
(define sgr (build-reduced-state-graph rs ctx))
(graphviz (pretty-print-reduced-state-graph sgr))))
;;; Builds the interactive process driven by the given context
;;; sequence. The output is a list of pairs of lists in which the
;;; first element is the current context and the second element is the