All Manuals > LispWorks IDE User Guide > 6 Manipulating Graphs


6.7 Using graphs in your programs

You can read about the CAPI class graph-pane in the CAPI Reference Manual for detailed API information for using graphs in your own programs. We will also look at a short example in this section. The following code listing defines a callback function and creates a graph-pane object:

(defun node-children (node)
  (if (equal node 'pets)
      (list 'dog 'parrot)
    (if (equal node 'dog)
        (list 'Kito 'Otis 'Sammy 'Teddy)
      (if (equal node 'parrot)
          (list 'Brady)))))
(setq test-graph
       (make-instance 'capi:graph-pane
                      :roots '(pets)
       :best-width 300
       :best-height 400))

The children function node-children should return nil for a leaf node in the graph or a list of child nodes for a non-leaf node. Sample Graph from a User Program shows the generated graph-pane.

Figure 6.12 Sample Graph from a User Program

LispWorks IDE User Guide (Windows version) - 25 Nov 2011