== graphviz
Some Graphviz abstractions
[[toc:]]
=== {{default-width}}
default-width → 1600
(define default-width (make-parameter 1600))
=== {{write-dot-preamble}}
(write-dot-preamble) → unspecified
(write-dot-preamble width height font-size) → unspecified
Write a dot preamble.
; width : Width in pixels
; height : Height in pixels
; font-size : Font-size in pt
(define write-dot-preamble
(case-lambda
(()
(write-dot-preamble (default-width) (default-height) (default-font-size)))
((width height font-size)
(display "digraph G {")
(unless
(null? (default-graph-attributes))
(format
#t
"graph [~a];"
(attributes->string (default-graph-attributes))))
(unless
(null? (default-node-attributes))
(format #t "node [~a];" (attributes->string (default-node-attributes))))
(unless
(null? (default-edge-attributes))
(format #t "edge [~a];" (attributes->string (default-edge-attributes))))
(if (and width height)
(begin
(format #t "graph [fontsize=~a, ratio=fill];" font-size)
(let ((width-in-inches (px->in width))
(height-in-inches (px->in height)))
(format
#t
"graph [viewport=\"~a,~a\", size=\"~a,~a!\"];"
(in->dot width-in-inches)
(in->dot height-in-inches)
width-in-inches
height-in-inches)))))))
=== {{write-dot-postscript}}
(write-dot-postscript) → unspecified
Write the dot postscript
(define (write-dot-postscript) (display "}"))
=== {{write-node}}
(write-node label) → unspecified
(write-node label attributes) → unspecified
Write a node
; label : The node's label
; attributes : Other attributes of the node
(define write-node
(case-lambda
((label) (write-node label '()))
((label attributes)
(format #t "~a [~a];" label (attributes->string attributes)))))
=== {{write-edge}}
(write-edge whence whither) → unspecified
(write-edge whence whither attributes) → unspecified
Write an edge
; whence : The label whence
; whither : The lable whither
; attributes : Other attributes of the edge
(define write-edge
(case-lambda
((whence whither) (write-edge whence whither '()))
((whence whither attributes) (format #t "~a -> ~a;" whence whither))))
=== About this egg
==== Author
[[/users/klutometis|Peter Danenberg]]
==== Colophon
Documented by [[/egg/cock|cock]].