You are looking at historical revision 29581 of this page. It may differ significantly from its current revision.

graphviz

Some Graphviz abstractions

default-width

[parameter] default-width → 1600

Default width for graphs

(define default-width (make-parameter 1600))

default-height

[parameter] default-height → 900

Default width for graphs

(define default-height (make-parameter 900))

default-font-size

[parameter] default-font-size → 48.0

Default font-size for graphs

(define default-font-size (make-parameter 48.0))

default-node-attributes

[parameter] default-node-attributes → (quote ())

Default node attributes

(define default-node-attributes (make-parameter '()))

Examples

(default-node-attributes (quote ((font . monospace))))

default-edge-attributes

[parameter] default-edge-attributes → (quote ())

Default edge attributes

(define default-edge-attributes (make-parameter '()))

Examples

(default-edge-attributes (quote ((dir . none))))

default-graph-attributes

[parameter] default-graph-attributes → (quote ())

Default graph attributes

(define default-graph-attributes (make-parameter '()))

Examples

(default-graph-attributes (quote ((splines . true))))

write-graph-preamble

[procedure] (write-graph-preamble) → unspecified
[procedure] (write-graph-preamble graph-attributes) → unspecified
[procedure] (write-graph-preamble graph-attributes width height font-size) → unspecified

Write a graph preamble.

graph-attributes
Attributes of the graph
width
Width in pixels
height
Height in pixels
font-size
Font-size in pt
(define write-graph-preamble
  (case-lambda
    (() (write-graph-preamble '()))
    ((graph-attributes)
     (write-graph-preamble
       graph-attributes
       (default-width)
       (default-height)
       (default-font-size)))
    ((graph-attributes width height font-size)
     (display "digraph G {")
     (unless
       (null? graph-attributes)
       (format #t "graph [~a];" (attributes->string graph-attributes)))
     (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)))))))

Examples

(write-graph-preamble (quote ((splines-true))))

(write-node a '((label . "Big bang")))
(write-node b '((label . "Today")))
(write-edge a b '((label . "Entropy gradient")))
(write-graph-postamble)

write-graph-postamble

[procedure] (write-graph-postamble) → unspecified

Write the graph postamble.

(define (write-graph-postamble) (display "}"))

pos

[procedure] (pos x y) → unspecified

For placing nodes at specific positions in a unit graph using the pos

attribute, apply a linear scaling.
x
The x position
y
The y position
(define (pos x y) (format "~a,~a" (* x (linear-scale)) (* y (linear-scale))))

write-node

[procedure] (write-node label) → unspecified
[procedure] (write-node label attributes) → unspecified

Write a node

label
The node's label
attributes
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

[procedure] (write-edge whence whither) → unspecified
[procedure] (write-edge whence whither attributes) → unspecified

Write an edge

whence
The label whence
whither
The lable whither
attributes
Attributes of the edge
(define write-edge
  (case-lambda
    ((whence whither) (write-edge whence whither '()))
    ((whence whither attributes)
     (format
       #t
       "~a -> ~a [~a];"
       whence
       whither
       (attributes->string attributes)))))

About this egg

Author

Peter Danenberg

Colophon

Documented by cock.