Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing trees in Common Lisp

This question probably has an embarrassingly simple answer, but is there a Right Way to format/draw trees in Common Lisp? I've tried a few books as well as googling about, but the problem seems to fall between the cracks of the search terms.

Thanks in advance!

like image 643
wvoq Avatar asked May 20 '09 23:05

wvoq


3 Answers

What kind of trees do you want to draw?

SDRAW draws cons cell structures to a terminal. Similar: Draw Cons Tree.

If you have McCLIM, CLIM or a Lisp Machine, you can call the CLIM function CLIM:FORMAT-GRAPH-FROM-ROOT or CLIM:FORMAT-GRAPH-FROM-ROOTS.

If you use LispWorks, there is a graph pane.

If you want to draw plants use this one: L-Lisp.

plant drawing

like image 105
Rainer Joswig Avatar answered Dec 04 '22 23:12

Rainer Joswig


If you do decide to go with GraphViz, check out http://common-lisp.net/project/cl-graphviz

like image 34
jlf Avatar answered Dec 04 '22 23:12

jlf


If you don't find a better solution, I'd be inclined to emit a .dot file and then feed it to one of the Graphviz tools (like dot). The file format is really simple, and the tools can generate a variety of formats including PNG, SVG, PostScript and even image maps (for creating clickable graphs on web pages).

This approach probably only works for you if you want these graphs for your own use (eg: debugging) or you're generating them on a server. Calling out to a separate tool in a client app might have usability and/or licensing issues.

This isn't really a common-lisp specific solution, but I've used this approach from a few languages in the past.

like image 25
Laurence Gonsalves Avatar answered Dec 05 '22 00:12

Laurence Gonsalves