Page 168 Table of Contents Index Page 170
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E





Chapter 18

Graph Formatting

CLIM provides a mechanism for arranging arbitrary output in a graph. The following code
produces the graph shown in Figure 18.1.
 
 (defun graph-test (stream &optional (orientation :horizontal))
   (fresh-line stream)
   (macrolet ((make-node (&key name children)
                `(list* ,name ,children)))
     (flet ((node-name (node)
              (car node))
            (node-children (node)
              (cdr node)))
       (let* ((2a (make-node :name "2A"))
              (2b (make-node :name "2B"))
              (2c (make-node :name "2C"))
              (1a (make-node :name "1A" :children (list 2a 2b)))
              (1b (make-node :name "1B" :children (list 2b 2c)))
              (root (make-node :name "0" :children (list 1a 1b))))
         (format-graph-from-roots
           (list root)
           #'(lambda (node s)
               (write-string (node-name node) s))
           #'node-children
           :orientation orientation
           :stream stream)))))


Page 168 Table of Contents Index Page 170
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E