From ac2d03f953f933400f1171c4e77eab1fadd38cd2 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 22 Mar 2020 21:08:45 +0100 Subject: [PATCH] Add some tests for building signed interaction graphs from networks. Previously I only had functions for building interaction graphs from forms. These do not play well with networks randomly generated from truth tables. --- networks-tests.rkt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/networks-tests.rkt b/networks-tests.rkt index a94d7af..8d0a637 100644 --- a/networks-tests.rkt +++ b/networks-tests.rkt @@ -84,7 +84,8 @@ (let* ([n #hash((a . (not b)) (b . a))] [doms (make-boolean-domains '(a b))] [sig1 (build-signed-interaction-graph/form n doms)] - [sig2 (build-boolean-signed-interaction-graph/form n)]) + [sig2 (build-boolean-signed-interaction-graph/form n)] + [sig3 (build-boolean-signed-interaction-graph (nn n))]) (check-equal? (get-interaction-sign (nn n) doms 'a 'b) '+) (check-equal? (get-interaction-sign (nn n) doms 'b 'a) '-) @@ -108,7 +109,14 @@ (check-false (has-edge? sig2 'c 'b)) (check-false (has-edge? sig2 'c 'a)) (check-equal? (edge-weight sig2 'a 'b) '+) - (check-equal? (edge-weight sig2 'b 'a) '-))) + (check-equal? (edge-weight sig2 'b 'a) '-) + + (check-true (has-vertex? sig3 'a)) + (check-true (has-vertex? sig3 'b)) + (check-equal? (edge-weight sig3 'a 'a) '+) + (check-equal? (edge-weight sig3 'b 'b) '+) + (check-equal? (edge-weight sig3 'a 'b) '+) + (check-equal? (edge-weight sig3 'b 'a) '-))) (test-case "Dynamics of networks" (check-equal? (pretty-print-state (st '((a . #f) (b . 3) (c . 4)))) "a:#f b:3 c:4")