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
48
networks.rkt
48
networks.rkt
|
@ -469,11 +469,10 @@
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(test-case "interaction?"
|
(test-case "interaction?"
|
||||||
(define n-bool (hash 'x '(not y)
|
(define n1 (forms->boolean-network
|
||||||
'y 'x
|
(hash 'x '(not y)
|
||||||
'z '(and y z)))
|
'y 'x
|
||||||
(define bool-doms (make-boolean-domains '(x y z)))
|
'z '(and y z))))
|
||||||
(define n1 (network-form->network (network-form n-bool bool-doms)))
|
|
||||||
(check-true (interaction? n1 'x 'y))
|
(check-true (interaction? n1 'x 'y))
|
||||||
(check-true (interaction? n1 'y 'x))
|
(check-true (interaction? n1 'y 'x))
|
||||||
(check-false (interaction? n1 'x 'z))
|
(check-false (interaction? n1 'x 'z))
|
||||||
|
@ -529,13 +528,12 @@
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(test-case "get-interaction-sign"
|
(test-case "get-interaction-sign"
|
||||||
(define n-bool (hash 'x '(not y)
|
(define n1 (forms->boolean-network
|
||||||
'y 'x
|
(hash 'x '(not y)
|
||||||
'z '(and y z)
|
'y 'x
|
||||||
't '(or (and (not x) y)
|
'z '(and y z)
|
||||||
(and x (not y)))))
|
't '(or (and (not x) y)
|
||||||
(define bool-doms (make-boolean-domains '(x y z t)))
|
(and x (not y))))))
|
||||||
(define n1 (network-form->network (network-form n-bool bool-doms)))
|
|
||||||
(check-equal? (get-interaction-sign n1 'x 'y) 1)
|
(check-equal? (get-interaction-sign n1 'x 'y) 1)
|
||||||
(check-equal? (get-interaction-sign n1 'y 'x) -1)
|
(check-equal? (get-interaction-sign n1 'y 'x) -1)
|
||||||
(check-false (get-interaction-sign n1 'x 'z))
|
(check-false (get-interaction-sign n1 'x 'z))
|
||||||
|
@ -575,13 +573,12 @@
|
||||||
[skip-expensive-tests?
|
[skip-expensive-tests?
|
||||||
(displayln "Skipping test case build-interaction-graph.")]
|
(displayln "Skipping test case build-interaction-graph.")]
|
||||||
[else
|
[else
|
||||||
(define n-bool (hash 'x '(not y)
|
(define n1 (forms->boolean-network
|
||||||
'y 'x
|
(hash 'x '(not y)
|
||||||
'z '(and y z)
|
'y 'x
|
||||||
't '(or (and (not x) y)
|
'z '(and y z)
|
||||||
(and x (not y)))))
|
't '(or (and (not x) y)
|
||||||
(define bool-doms (make-boolean-domains '(x y z t)))
|
(and x (not y))))))
|
||||||
(define n1 (network-form->network (network-form n-bool bool-doms)))
|
|
||||||
(check-equal? (graphviz (build-interaction-graph/form n1))
|
(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")
|
"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)
|
(define n-multi (hash 'x '(min (+ y 1) 2)
|
||||||
|
@ -617,13 +614,12 @@
|
||||||
[skip-expensive-tests?
|
[skip-expensive-tests?
|
||||||
(displayln "Skipping test case build-signed-interaction-graph.")]
|
(displayln "Skipping test case build-signed-interaction-graph.")]
|
||||||
[else
|
[else
|
||||||
(define n-bool (hash 'x '(not y)
|
(define n1 (forms->boolean-network
|
||||||
'y 'x
|
(hash 'x '(not y)
|
||||||
'z '(and y z)
|
'y 'x
|
||||||
't '(or (and (not x) y)
|
'z '(and y z)
|
||||||
(and x (not y)))))
|
't '(or (and (not x) y)
|
||||||
(define bool-doms (make-boolean-domains '(x y z t)))
|
(and x (not y))))))
|
||||||
(define n1 (network-form->network (network-form n-bool bool-doms)))
|
|
||||||
(check-equal? (graphviz (build-signed-interaction-graph/form n1))
|
(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")
|
"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)
|
(define n-multi (hash 'x '(min (+ y 1) 2)
|
||||||
|
|
Loading…
Reference in a new issue