networks, IG: Use forms->boolean-network.
IG = interaction graph
This commit is contained in:
parent
ec3c74b5e2
commit
3e35b8e0ab
1 changed files with 22 additions and 26 deletions
28
networks.rkt
28
networks.rkt
|
@ -469,11 +469,10 @@
|
|||
|
||||
(module+ test
|
||||
(test-case "interaction?"
|
||||
(define n-bool (hash 'x '(not y)
|
||||
(define n1 (forms->boolean-network
|
||||
(hash 'x '(not y)
|
||||
'y 'x
|
||||
'z '(and y z)))
|
||||
(define bool-doms (make-boolean-domains '(x y z)))
|
||||
(define n1 (network-form->network (network-form n-bool bool-doms)))
|
||||
'z '(and y z))))
|
||||
(check-true (interaction? n1 'x 'y))
|
||||
(check-true (interaction? n1 'y 'x))
|
||||
(check-false (interaction? n1 'x 'z))
|
||||
|
@ -529,13 +528,12 @@
|
|||
|
||||
(module+ test
|
||||
(test-case "get-interaction-sign"
|
||||
(define n-bool (hash 'x '(not y)
|
||||
(define n1 (forms->boolean-network
|
||||
(hash 'x '(not y)
|
||||
'y 'x
|
||||
'z '(and y z)
|
||||
't '(or (and (not x) y)
|
||||
(and x (not y)))))
|
||||
(define bool-doms (make-boolean-domains '(x y z t)))
|
||||
(define n1 (network-form->network (network-form n-bool bool-doms)))
|
||||
(and x (not y))))))
|
||||
(check-equal? (get-interaction-sign n1 'x 'y) 1)
|
||||
(check-equal? (get-interaction-sign n1 'y 'x) -1)
|
||||
(check-false (get-interaction-sign n1 'x 'z))
|
||||
|
@ -575,13 +573,12 @@
|
|||
[skip-expensive-tests?
|
||||
(displayln "Skipping test case build-interaction-graph.")]
|
||||
[else
|
||||
(define n-bool (hash 'x '(not y)
|
||||
(define n1 (forms->boolean-network
|
||||
(hash 'x '(not y)
|
||||
'y 'x
|
||||
'z '(and y z)
|
||||
't '(or (and (not x) y)
|
||||
(and x (not y)))))
|
||||
(define bool-doms (make-boolean-domains '(x y z t)))
|
||||
(define n1 (network-form->network (network-form n-bool bool-doms)))
|
||||
(and x (not y))))))
|
||||
(check-equal? (graphviz (build-interaction-graph/form n1))
|
||||
"digraph G {\n\tnode0 [label=\"y\"];\n\tnode1 [label=\"z\"];\n\tnode2 [label=\"x\"];\n\tnode3 [label=\"t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode0 -> node2;\n\t\tnode1 -> node1;\n\t}\n\tsubgraph D {\n\t\tnode0 -> node3;\n\t\tnode0 -> node1;\n\t\tnode2 -> node3;\n\t}\n}\n")
|
||||
(define n-multi (hash 'x '(min (+ y 1) 2)
|
||||
|
@ -617,13 +614,12 @@
|
|||
[skip-expensive-tests?
|
||||
(displayln "Skipping test case build-signed-interaction-graph.")]
|
||||
[else
|
||||
(define n-bool (hash 'x '(not y)
|
||||
(define n1 (forms->boolean-network
|
||||
(hash 'x '(not y)
|
||||
'y 'x
|
||||
'z '(and y z)
|
||||
't '(or (and (not x) y)
|
||||
(and x (not y)))))
|
||||
(define bool-doms (make-boolean-domains '(x y z t)))
|
||||
(define n1 (network-form->network (network-form n-bool bool-doms)))
|
||||
(and x (not y))))))
|
||||
(check-equal? (graphviz (build-signed-interaction-graph/form n1))
|
||||
"digraph G {\n\tnode0 [label=\"y\"];\n\tnode1 [label=\"z\"];\n\tnode2 [label=\"x\"];\n\tnode3 [label=\"t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t\tnode1 -> node1 [label=\"1\"];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node2 [label=\"-1\"];\n\t\tnode0 -> node3 [label=\"0\"];\n\t\tnode0 -> node1 [label=\"1\"];\n\t\tnode2 -> node3 [label=\"0\"];\n\t\tnode2 -> node0 [label=\"1\"];\n\t}\n}\n")
|
||||
(define n-multi (hash 'x '(min (+ y 1) 2)
|
||||
|
|
Loading…
Reference in a new issue