CU Arcadia Project: Tk Canvas Graph Layout



This software is a mild re-write and a re-packaging of a portion of the tkMegaWidget and tkIcon system of of Sven Delmas ( of the Tech. Univ. Berlin. Sven's TkIcon system provided a very nice and useful mechanism for defining graphs (node icons + edge canvas items) and doing layout over them.

This re-package was constructed because the original tkIcon+tkMegaWidget system, made me uncomfortable with the amount of modification to the Tk sources that it required. It was a bit too heavyweight. This re-packaging sacrifices some features for simpler insertion into Tk (see installation below).

Description<\h2> The Tk canvas window type has been augmented to allow graph layout of the selected canvas items. It operates by associating extra graph information with the canvas. Items are created using the normal canvas operations. Any existing item may, by a separate command to the canvas, be added to or removed from the list of items layed-out by the graph. Four styles of layout are currently supported: ISI, Tree, Random, and Matrix. Some simple experiments will demonstrate the differences. A new type of item, Edge (taken from tkIcon) is provided as the means of laying edges between nodes. Non-edge canvas items are treated as nodes, but not all canvas item types can be handled by the graph layout code. A more complete description is provided by the graph.n file.


The following source files are in the tar file of the distribution: tkCanvas.c, tkCanvas.h, tkCanvEdge.c, layout.c, layout.h, There are also some additional files such as graph.n,, graphdemo.tcl, HISTORY, and README.html (this file).

In order to install, perform the following steps.

  1. Un-tar the tklayout.tar file, this will produce a directory named tklayout.
  2. Copy the files tkCanvas.c, tkCanvas.h, tkCanvEdge.c, layout.c, and layout.h into your tk3.6 directory. WARNING, this will overwrite the existing tkCanvas.c and tkCanvas.h, so you may want to save them. Note that I have tried to wrap all changes within an ifdef of CANVASLAYOUT.
  3. Modify your Makefile to build tkCanvas.o and layout.o. You can look at the tklayout/ to see how this might be done (or use that directly).
  4. Re-build and re-install Tk3.6.
  5. Start up the wish program and source tklayout/graphdemo.tcl. Execute the demo command to see if things appear to be working. <\ol>

    Contact and Bug Reports:

    This is a rather quick and dirty re-packaging, and has not been thoroughly tested, so I am sure that many bugs exist. I would appreciate hearing about them, and better yet, receiving patches.
    Dennis Heimbigner (