Implement build-state-graph, build-state-graph/annotated, build-state-graph*.

This commit is contained in:
Sergiu Ivanov 2022-09-15 16:55:44 +02:00
parent 857b33ad71
commit 567a721c8f
2 changed files with 19 additions and 5 deletions

View File

@ -24,13 +24,18 @@
(step s)))))
(: build-state-graph (-> (Listof State) Graph))
(define/abstract/error (build-state-graph sts))
(define/public (build-state-graph sts)
(build-state-graph* sts 'full))
(: build-state-graph/annotated (-> (Listof State) Graph))
(define/abstract/error (build-state-graph/annotated sts))
(define/public (build-state-graph/annotated sts)
(build-state-graph*/annotated sts 'full))
(: build-state-graph* (-> (Listof State) (U Positive-Integer 'full) Graph))
(define/abstract/error (build-state-graph* sts nsteps))
(define/public (build-state-graph* sts nsteps)
(unweighted-graph/directed
(assert-type (get-edges (build-state-graph*/annotated sts nsteps))
(Listof (List Any Any)))))
(: build-state-graph*/annotated (-> (Listof State) (U Positive-Integer 'full) Graph))
(define/public (build-state-graph*/annotated sts nsteps)

View File

@ -567,8 +567,17 @@
(check-equal? (graphviz (send dyn-syn build-state-graph*/annotated (list s1) 'full))
"digraph G {\n\tnode0 [label=\"'#hash((x . #t) (y . #f) (z . #f))\"];\n\tnode1 [label=\"'#hash((x . #f) (y . #t) (z . #f))\"];\n\tnode2 [label=\"'#hash((x . #t) (y . #t) (z . #f))\"];\n\tnode3 [label=\"'#hash((x . #f) (y . #f) (z . #f))\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node2 [label=\"'(x y z)\"];\n\t\tnode1 -> node3 [label=\"'(x y z)\"];\n\t\tnode2 -> node1 [label=\"'(x y z)\"];\n\t\tnode3 -> node0 [label=\"'(x y z)\"];\n\t}\n}\n")
)
)
)
(test-case "dynamics%:build-state-graph*"
(check-equal? (graphviz (send dyn-syn build-state-graph* (list s1) 2))
"digraph G {\n\tnode0 [label=\"'#hash((x . #t) (y . #f) (z . #f))\"];\n\tnode1 [label=\"'#hash((x . #f) (y . #f) (z . #f))\"];\n\tnode2 [label=\"'#hash((x . #t) (y . #t) (z . #f))\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node2 [];\n\t\tnode1 -> node0 [];\n\t}\n}\n")
(check-equal? (graphviz (send dyn-syn build-state-graph* (list s1) 'full))
"digraph G {\n\tnode0 [label=\"'#hash((x . #t) (y . #f) (z . #f))\"];\n\tnode1 [label=\"'#hash((x . #f) (y . #f) (z . #f))\"];\n\tnode2 [label=\"'#hash((x . #f) (y . #t) (z . #f))\"];\n\tnode3 [label=\"'#hash((x . #t) (y . #t) (z . #f))\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node3 [];\n\t\tnode1 -> node0 [];\n\t\tnode2 -> node1 [];\n\t\tnode3 -> node2 [];\n\t}\n}\n"))
(test-case "dynamics%:build-state-graph/annotated"
(check-equal? (graphviz (send dyn-syn build-state-graph/annotated (list s1)))
(graphviz (send dyn-syn build-state-graph*/annotated (list s1) 'full))))
(test-case "dynamics%:build-state-graph"
(check-equal? (graphviz (send dyn-syn build-state-graph (list s1)))
(graphviz (send dyn-syn build-state-graph* (list s1) 'full))))))
)
(require 'typed)