source: project/wiki/eggref/4/graphviz @ 29454

Last change on this file since 29454 was 29454, checked in by Peter Danenberg, 7 years ago

graphviz: Initial docs

File size: 2.3 KB
Line 
1== graphviz
2
3Some Graphviz abstractions
4[[toc:]]
5=== {{default-width}}
6<parameter>default-width → 1600</parameter>
7
8<enscript highlight="scheme">(define default-width (make-parameter 1600))
9</enscript>
10=== {{write-dot-preamble}}
11<procedure>(write-dot-preamble) → unspecified</procedure>
12<procedure>(write-dot-preamble width height font-size title) → unspecified</procedure>
13Write a dot preamble.
14; width : Width in pixels
15; height : Height in pixels
16; font-size : Font-size in pt
17; title : Title of the graph
18<enscript highlight="scheme">(define write-dot-preamble
19  (case-lambda
20    (()
21     (write-dot-preamble
22       (default-width)
23       (default-height)
24       (default-font-size)
25       (default-title)))
26    ((width height font-size title)
27     (display "digraph G {")
28     (display "node [style=filled, fontname=monospace, shape=circle];")
29     (display "edge [fontname=monospace, dir=none];")
30     (if (and width height)
31       (begin
32         (format #t "graph [fontsize=~a, ratio=fill]" font-size)
33         (let ((width-in-inches (px->in width))
34               (height-in-inches (px->in height)))
35           (format
36             #t
37             "graph [viewport=\"~a,~a\", size=\"~a,~a!\"];"
38             (in->dot width-in-inches)
39             (in->dot height-in-inches)
40             width-in-inches
41             height-in-inches)))))))
42</enscript>
43=== {{write-dot-postscript}}
44<procedure>(write-dot-postscript) → unspecified</procedure>
45Write the dot postscript
46
47<enscript highlight="scheme">(define (write-dot-postscript) (display "}"))
48</enscript>
49=== {{write-node}}
50<procedure>(write-node label x y color) → unspecified</procedure>
51Write a node
52; label : The node's label
53; x : The x-coordinate of the node
54; y : The y-coordinate of the node
55<enscript highlight="scheme">(define (write-node label x y color)
56  (format
57    #t
58    "~a [pos=\"~a,~a\", color=~a];"
59    label
60    (* x (linear-scale))
61    (* y (linear-scale))
62    color))
63</enscript>
64=== {{write-edge}}
65<procedure>(write-edge whence whither) → unspecified</procedure>
66Write an edge
67; whence : The label whence
68; whither : The lable whither
69<enscript highlight="scheme">(define (write-edge whence whither) (format #t "~a -> ~a;" whence whither))
70</enscript>
71=== About this egg
72
73==== Author
74
75[[/users/klutometis|Peter Danenberg]]
76==== Colophon
77
78Documented by [[/egg/cock|cock]].
Note: See TracBrowser for help on using the repository browser.