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

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

graphviz: Update docs.

File size: 2.8 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) → unspecified</procedure>
13Write a dot preamble.
14; width : Width in pixels
15; height : Height in pixels
16; font-size : Font-size in pt
17<enscript highlight="scheme">(define write-dot-preamble
18  (case-lambda
19    (()
20     (write-dot-preamble (default-width) (default-height) (default-font-size)))
21    ((width height font-size)
22     (display "digraph G {")
23     (unless
24       (null? (default-graph-attributes))
25       (format
26         #t
27         "graph [~a];"
28         (attributes->string (default-graph-attributes))))
29     (unless
30       (null? (default-node-attributes))
31       (format #t "node [~a];" (attributes->string (default-node-attributes))))
32     (unless
33       (null? (default-edge-attributes))
34       (format #t "edge [~a];" (attributes->string (default-edge-attributes))))
35     (if (and width height)
36       (begin
37         (format #t "graph [fontsize=~a, ratio=fill];" font-size)
38         (let ((width-in-inches (px->in width))
39               (height-in-inches (px->in height)))
40           (format
41             #t
42             "graph [viewport=\"~a,~a\", size=\"~a,~a!\"];"
43             (in->dot width-in-inches)
44             (in->dot height-in-inches)
45             width-in-inches
46             height-in-inches)))))))
47</enscript>
48=== {{write-dot-postscript}}
49<procedure>(write-dot-postscript) → unspecified</procedure>
50Write the dot postscript
51
52<enscript highlight="scheme">(define (write-dot-postscript) (display "}"))
53</enscript>
54=== {{write-node}}
55<procedure>(write-node label) → unspecified</procedure>
56<procedure>(write-node label attributes) → unspecified</procedure>
57Write a node
58; label : The node's label
59; attributes : Other attributes of the node
60<enscript highlight="scheme">(define write-node
61  (case-lambda
62    ((label) (write-node label '()))
63    ((label attributes)
64     (format #t "~a [~a];" label (attributes->string attributes)))))
65</enscript>
66=== {{write-edge}}
67<procedure>(write-edge whence whither) → unspecified</procedure>
68<procedure>(write-edge whence whither attributes) → unspecified</procedure>
69Write an edge
70; whence : The label whence
71; whither : The lable whither
72; attributes : Other attributes of the edge
73<enscript highlight="scheme">(define write-edge
74  (case-lambda
75    ((whence whither) (write-edge whence whither '()))
76    ((whence whither attributes) (format #t "~a -> ~a;" whence whither))))
77</enscript>
78=== About this egg
79
80==== Author
81
82[[/users/klutometis|Peter Danenberg]]
83==== Colophon
84
85Documented by [[/egg/cock|cock]].
Note: See TracBrowser for help on using the repository browser.