The roots of the graph.
Returns the children of a node.
A keyword denoting how to layout the nodes.
The class of pane to represent nodes.
A graph pane calculates the graph by calling the children-function
on each of its roots, and then calling it again on each of the children recursively until it runs out of children. The children-function
gets called with a node of the graph and should return a list of the children of that node.
The layout-function
tells the graph pane how to lay out its children. It can take these values:
Lay the graph out from the left to the right.
Lay the graph out from the top down.
Lay the graph out from the right to the left.
Lay the graph out from the bottom up.
When a graph pane wants to display nodes and edges, it creates instances of node-pinboard-class
and edge-pinboard-class
which default to item-pinboard-object
and line-pinboard-object
respectively. These classes must be subclasses of simple-pane
or pinboard-object
, and there are some examples of the use of these keywords below.
The node-pane-function
is called to create a node for each pane, and by default it creates an instance of node-pinboard-class
. It gets passed the graph pane and the node, and should return an instance of simple-pane
or pinboard-object
.
(defun node-children (node)
(when (< node 16)
(list (* node 2)
(1+ (* node 2)))))
(setq graph (capi:contain
(make-instance 'capi:graph-pane
:roots '(1)
:children-function
'node-children)
:best-width 300
:best-height 400
:process nil))
(setf (capi:graph-pane-roots graph) '(2 6))
(capi:contain (make-instance 'capi:graph-pane
:roots '(1)
:children-function
'node-children
:layout-function
:top-down)
:best-width 300
:best-height 400)
(capi:contain (make-instance 'capi:graph-pane
:roots '(1)
:children-function
'node-children
:layout-function :top-down
:x-adjust :left)
:best-width 300
:best-height 400)
This example demonstrates a different style of graph output with right-angle edges and parent nodes being adjusted to the top instead of the center.
(capi:contain (make-instance
'capi:graph-pane
:roots '(1)
:children-function 'node-children
:y-adjust :top
:edge-pinboard-class
'capi:right-angle-line-pinboard-object)
:best-width 300
:best-height 400)
This example demonstrates the use of :node-pinboard-class
to specify that the nodes are drawn as push buttons.
(capi:contain (make-instance
'capi:graph-pane
:roots '(1)
:children-function 'node-children
:node-pinboard-class
'capi:push-button)
:best-width 300
:best-height 400)