Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

graphviz

Some Graphviz abstractions

  1. Outdated egg!
  2. graphviz
    1. default-width
    2. default-height
    3. default-font-size
    4. default-node-attributes
      1. Examples
    5. default-edge-attributes
      1. Examples
    6. default-graph-attributes
      1. Examples
    7. write-graph-preamble
      1. Examples
    8. write-graph-postamble
    9. pos
    10. write-node
    11. write-edge
    12. About this egg
      1. Author
      2. Repository
      3. License
      4. Dependencies
      5. Versions
      6. Colophon

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

Creating default node attributes

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

default-edge-attributes

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

Default edge attributes

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

Examples

Creating default edge attributes

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

default-graph-attributes

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

Default graph attributes

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

Examples

Creating default graph attributes

(default-graph-attributes '((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

A trivial graph

(write-graph-preamble '((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

Repository

https://github.com/klutometis/graphviz

License

BSD

Dependencies

Versions

0.2
Add dependencies.
0.3
Get rid of 0.1.
0.4
Abstract out attributes.
0.5
Add test-exit.
0.6
Add attributes to edge.
0.7
Sparser defaults
0.8
Write-graph-preamble, &c.
0.8.1
Use hahn.
0.8.2
Version should be a string.

Colophon

Documented by hahn.