From d5382eacda1abc0916fc7d6776f40e283c3970f8 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Tue, 20 Sep 2022 11:40:21 +0200 Subject: [PATCH] Type pretty-print-state-graph-with. --- networks.rkt | 8 +++++++- scribblings/networks.scrbl | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/networks.rkt b/networks.rkt index f679f1e..09038bd 100644 --- a/networks.rkt +++ b/networks.rkt @@ -35,7 +35,7 @@ Modality Mode dynamics% Dynamics% make-syn make-asyn make-asyn-dynamics make-syn-dynamics pretty-print-state - pretty-print-boolean-state + pretty-print-boolean-state pretty-print-state-graph-with ) (define-type (State a) (VariableMapping a)) @@ -675,6 +675,12 @@ (check-equal? (pretty-print-boolean-state (hash 'a #f 'b #t 'c #t)) "a:0 b:1 c:1"))) + + (: pretty-print-state-graph-with (-> Graph (-> Any Any) Graph)) + (define (pretty-print-state-graph-with gr pprinter) + (define (e-pprinter/any [x : Any]) + (pretty-print-set-sets (assert-type x (Setof (Setof Any))))) + (update-graph gr #:v-func pprinter #:e-func e-pprinter/any)) ) (require 'typed) diff --git a/scribblings/networks.scrbl b/scribblings/networks.scrbl index 8ff3883..33ea3ff 100644 --- a/scribblings/networks.scrbl +++ b/scribblings/networks.scrbl @@ -485,6 +485,15 @@ all other values with 1. } +@defproc[(pretty-print-state-graph-with [gr Graph] [pprinter (-> Any Any)]) Graph]{ + +Given a state graph @racket[gr] and the pretty-printer for states +@racket[pprinter], build a new state graph in which the nodes are +pretty-printed with @racket[pprinter] and the edges with +@racket[pretty-print-set-sets]. + +} + @section{Inferring interaction graphs} This section provides inference of both unsigned and signed interaction graphs.