diff --git a/example/dots/examplem7LpTs.svg b/example/dots/examplem7LpTs.svg index b2e115e..920649e 100644 --- a/example/dots/examplem7LpTs.svg +++ b/example/dots/examplem7LpTs.svg @@ -4,161 +4,161 @@ - - + + G - + node0 - -a:#f c:#f b:#t + +a:#f b:#f c:#f - - -node1 - -a:#t c:#f b:#t - - - -node0->node1 - - - - - -node2 - -a:#f c:#f b:#f - - - -node0->node2 - - - - - -node6 - -a:#f c:#t b:#t - - + -node0->node6 - - - - -node1->node1 - - - - -node3 - -a:#t c:#f b:#f - - - -node1->node3 - - - - - -node7 - -a:#t c:#t b:#t - - - -node1->node7 - - - - -node2->node2 - - - - -node4 - -a:#f c:#t b:#f - - - -node2->node4 - - - - -node3->node2 - - - - - -node3->node3 - +node0->node0 + node5 - -a:#t c:#t b:#f + +a:#f b:#f c:#t - - -node3->node5 - + + +node0->node5 + + + + +node1 + +a:#f b:#t c:#f + + + +node1->node0 + + + + + +node3 + +a:#f b:#t c:#t + + + +node1->node3 + + + + +node7 + +a:#t b:#t c:#f + + + +node1->node7 + + + + + +node2 + +a:#t b:#f c:#f + + + +node2->node0 + + + + + +node2->node2 + + + + +node6 + +a:#t b:#f c:#t + + + +node2->node6 + + + + +node3->node3 + + + + +node4 + +a:#t b:#t c:#t + + + +node3->node4 + + node4->node4 - + node4->node6 - - + + - + + +node4->node7 + + + -node5->node4 - - +node5->node3 + + node5->node5 - + + + + +node6->node5 + + node6->node6 - + - - -node6->node7 - - - - + -node7->node5 - - +node7->node2 + + node7->node7 - + diff --git a/example/dots/examplex1Irnk.svg b/example/dots/examplex1Irnk.svg index 622b156..c4523bc 100644 --- a/example/dots/examplex1Irnk.svg +++ b/example/dots/examplex1Irnk.svg @@ -4,161 +4,161 @@ - - + + G - + node0 - -a:0 c:0 b:0 + +a:0 b:0 c:1 node0->node0 - - - - -node1 - -a:0 c:1 b:0 - - - -node0->node1 - - - - -node1->node1 - + node2 - -a:0 c:1 b:1 + +a:0 b:1 c:1 - + -node1->node2 - - - - - -node2->node2 - +node0->node2 + + node4 - -a:1 c:1 b:1 + +a:0 b:0 c:0 - + + +node0->node4 + + + + +node1 + +a:1 b:0 c:1 + + -node2->node4 - - +node1->node0 + + - - -node6 - -a:0 c:0 b:1 - - - -node2->node6 - - - - -node3 - -a:1 c:0 b:0 - - - -node3->node0 - - - - - -node3->node3 - + + +node1->node1 + node7 - -a:1 c:1 b:0 + +a:1 b:0 c:0 - - -node3->node7 - + + +node1->node7 + - - -node4->node4 - + + +node2->node2 + node5 - -a:1 c:0 b:1 + +a:0 b:1 c:0 - - -node4->node5 - + + +node2->node5 + - + + +node6 + +a:1 b:1 c:1 + + + +node2->node6 + + + + + +node3 + +a:1 b:1 c:0 + + + +node3->node3 + + + + +node3->node6 + + + -node4->node7 - - +node3->node7 + + + + + +node4->node4 + - -node5->node3 - - - - - -node5->node5 - - - -node6->node0 - - +node5->node3 + + - + + +node5->node4 + + + + -node6->node5 - - +node6->node1 + + - + + +node6->node6 + + + -node7->node1 - - +node7->node4 + + node7->node7 - + diff --git a/networks-tests.rkt b/networks-tests.rkt index b8d8742..a2ae83e 100644 --- a/networks-tests.rkt +++ b/networks-tests.rkt @@ -111,8 +111,8 @@ (check-equal? (edge-weight sig2 'b 'a) -1))) (test-case "Dynamics of networks" - (check-equal? (pretty-print-state (st '((a . #f) (b . 3)))) "a:#f b:3") - (check-equal? (pretty-print-boolean-state (st '((a . #f) (b . #t)))) "a:0 b:1") + (check-equal? (pretty-print-state (st '((a . #f) (b . 3) (c . 4)))) "a:#f b:3 c:4") + (check-equal? (pretty-print-boolean-state (st '((a . #f) (b . #t) (c . #t)))) "a:0 b:1 c:1") (let ([vars '(a b c)]) (check-equal? (make-asyn vars) (set (set 'a) (set 'b) (set 'c))) (check-equal? (make-syn vars) (set (set 'a 'b 'c)))) diff --git a/networks.rkt b/networks.rkt index c984b97..002861f 100644 --- a/networks.rkt +++ b/networks.rkt @@ -331,14 +331,14 @@ ;;; Pretty-prints a state of the network. (define (pretty-print-state s) - (string-join (for/list ([(key val) s]) (format "~a:~a" key val)))) + (string-join (hash-map s (λ (key val) (format "~a:~a" key val)) #t))) ;;; Converts any non-#f value to 1 and #f to 0. (define (any->boolean x) (if x 1 0)) ;;; Pretty-prints a state of the network to Boolean values 0 or 1. (define (pretty-print-boolean-state s) - (string-join (for/list ([(key val) s]) (format "~a:~a" key (any->boolean val))))) + (string-join (hash-map s (λ (key val) (format "~a:~a" key (any->boolean val))) #t))) ;;; Given a state graph and a pretty-printer for states build a new ;;; state graph with pretty-printed vertices.