S-Dot: A Common Lisp Interface to Graphviz Dot | ||||||||||||||||||||||||||||||||||||
| What is S-Dot? | S-Dot is an S-Expression syntax for the input language of the 'Dot' graph drawing tool from the AT&T GraphViz suite. With S-Dot, you can render 'Dot' graphs from within Common Lisp. S-Dot is the little sister of DotML. | |||||||||||||||||||||||||||||||||||
| Sponsored links: | ||||||||||||||||||||||||||||||||||||
| Example 1/1: | ||||||||||||||||||||||||||||||||||||
| Source code: |
| |||||||||||||||||||||||||||||||||||
| How do I use it? | First, you have to type or generate an s-expression such as the one above. The file s-dot.lisp contains the simple syntax checking function (check-syntax): (check-syntax '(graph ((label "foo"))
(node ((id "bar") (baz "123")))
(edge ((from "bar") (to "bar")))))... raises this error: attribute BAZ is not allowed in NODE elements,
context: (NODE ((ID bar) (BAZ 123)))
[Condition of type SIMPLE-ERROR]The function (s-dot->dot <stream> <graph ...) (also in s-dot.lisp) generates the dot code: (s-dot->dot t '(graph ((label "foo"))
(node ((id "bar"))) (edge ((from "bar") (to "bar")))))... results in this (shortened) output: digraph g {compound="true";label="foo";
node[label="bar"]{bar}; edge bar->bar;}s-dot.lisp also contains an example how to invoke the dot tool on the generated code: (defun render-s-dot (file-name format graph &key (check-syntax t))
(let ((dot-file-name
(make-pathname :directory (pathname-directory file-name)
:name (pathname-name file-name)
:type "dot")))
(with-open-file (stream dot-file-name :direction :output
:if-exists :supersede
:if-does-not-exist :create)
(s-dot->dot stream graph :check-syntax check-syntax))
(asdf:run-shell-command
(format nil "dot -o ~a -T~a ~a"
file-name format dot-file-name)))
However, this is only an example. Note that it is faster to directly pipe the data to the 'dot' tool. | |||||||||||||||||||||||||||||||||||
| Where do I get it? | S-DOT can be downloaded from http://martin-loetzsch.de/S-DOT/s-dot.tar.gz. The current version is 1.1. It can be also installed via ASDF-Install: (asdf-install:install 's-dot) After successful installation, S-DOT can be loaded with (asdf:operate 'asdf:load-op :s-dot) | |||||||||||||||||||||||||||||||||||
| Is it free? | Yes it is. You can do whatever you want with it as long as you mention that you use it. See the licence for details. | |||||||||||||||||||||||||||||||||||
| Can I make donations? | Yes. If you find this stuff helpful, please consider a donation: Alternatively, there are also sponsored links on this page. | |||||||||||||||||||||||||||||||||||
| Sponsored links | ||||||||||||||||||||||||||||||||||||
| Copyright 2006-2010 by Martin Loetzsch (http://martin-loetzsch.de), all rights reserved. See the S-Dot licence for details. | ||||||||||||||||||||||||||||||||||||