Tcldot is the Tcl package for Graphviz: the Graph Visualization Software. It makes the dot graph renderer (for directed graphs) and the neato renderer (for undirected graphs) available to Tcl scripts.
See http://www.graphviz.org/pdf/tcldot.3tcl.pdf for the documentation.
Graphviz is available for Windows, Unix and MacOS X.
Let's take a simple directory hierarchy:
dir1
|---CVS
|---src
| |---doc
|
|---vfs
| |---bin
| |---config
| | |---ps
| | |---pw
| | |---pure
| |
| |---step1
| |---substep
|
|---www
|---cgi
The Tcl script starts like this:
package require Tk package require tcldot # a canvas to put the redered output into: set canv [canvas .canv] pack $canv
The first step is to make a description of this hierarchy in the dot language (find a summary here: [L1 ]). Note, that in this simple case, all directory names are unique. In reality, this would normally not be the case and the description would be more complicated.
set graph [dotstring {
digraph G {
dir1 -> CVS;
dir1 -> src -> doc;
dir1 -> vfs-> bin;
vfs -> config -> ps;
config -> pw -> pure;
vfs -> step1 -> substep;
dir1 -> www -> cgi;
}
}]Hmm, does not work. Gives a syntax error for the description ... - some changes made, works for me (EMJ).
The next step is to simply call the renderer:
eval [ $graph render $canv DOT ]
and size the window to match the bounding box of the graph layout
scan [$graph queryattr bb] "{%d %d %d %d}" ulx uly lrx lry
$canv configure -height [expr $lry + $uly + 5]p -width [expr $lrx + $ulx + 5]pFor another example, see XML Graph to canvas
schlenk If you need Tcldot for Windows, send me an email, i might find the dll and the VC6 project file.
2019-07-26 MiR: I recently tried to play around with tclodt and found major drawbacks. First, the only Windowsbuild I found was buggy (as it was unable to write to a filehandle) from https://fmt.ewi.utwente.nl/tools/torxviz/downloads.html Moreover, and this one is really annoing, if the underlying Tcldot catches a syntax error (e.g. via dotstring or dotread) it will NEVER recover and throw errors even on completly valid dotstrings. (Note: Seems not to be a bug limited to tcldot, even dot itsself show this behaviour...) Both together render tcldot more or less useless, since I have no chance to check syntax in advance and thus always risk to "crash" tcldot Any tipps for that ? Michael