== 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 title) → unspecified
Write a dot preamble.
; width : Width in pixels
; height : Height in pixels
; font-size : Font-size in pt
; title : Title of the graph
(define write-dot-preamble
(case-lambda
(()
(write-dot-preamble
(default-width)
(default-height)
(default-font-size)
(default-title)))
((width height font-size title)
(display "digraph G {")
(display "node [style=filled, fontname=monospace, shape=circle];")
(display "edge [fontname=monospace, dir=none];")
(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 x y color) → unspecified
Write a node
; label : The node's label
; x : The x-coordinate of the node
; y : The y-coordinate of the node
(define (write-node label x y color)
(format
#t
"~a [pos=\"~a,~a\", color=~a];"
label
(* x (linear-scale))
(* y (linear-scale))
color))
=== {{write-edge}}
(write-edge whence whither) → unspecified
Write an edge
; whence : The label whence
; whither : The lable whither
(define (write-edge whence whither) (format #t "~a -> ~a;" whence whither))
=== About this egg
==== Author
[[/users/klutometis|Peter Danenberg]]
==== Colophon
Documented by [[/egg/cock|cock]].