next up previous contents index CD CD Algorithms
Next: Planarity Detection and Embedding Up: Graph Problems: Polynomial-Time Previous: Drawing Graphs Nicely

Drawing Trees

  

  figure15830

Input description: A tree T, which is a graph without any cycles.

Problem description: A nice drawing of the tree T.

Discussion: There are as many reasons to want to draw trees as there are types of structures that trees represent. Consider software and debugging tools that illustrate the hierarchical structure of file system directories, or that trace the execution of a program through its subroutines.    

The primary issue in drawing trees is establishing whether you are drawing free or rooted trees:

Since trees are always planar graphs, they can and should be drawn such that no two edges cross.   Any of the planar drawing algorithms of Section gif could be used to do so. However, such algorithms are overkill, because much simpler algorithms can be used to construct planar drawings of trees. The spring-embedding heuristics of Section gif also work well on free trees,   although they may be too slow for many applications.

The most natural tree-drawing algorithms work with rooted trees. However, they can be used equally well with free trees by selecting one vertex to serve as the root of the drawing. This faux-root can be selected arbitrarily,   or, even better, by using a center vertex of the tree. A center vertex minimizes the maximum distance to other vertices. For trees, the center always consists of either one vertex or two adjacent vertices, so pick either one of them. Further, the center of a tree can be identified in linear time by repeatedly trimming all the leaves until only the center remains.

Your two primary options for drawing rooted trees are ranked and radial embeddings:

Implementations: Georg Sander maintains a comprehensive WWW page on graph drawing at http://www.cs.uni-sb.de/RW/users/sander/html/gstools.html. This should probably be your first stop in hunting down programs for tree drawing.

The best FTP-able package of graph drawing algorithms is GraphEd, by Michael Himsolt (himsolt@fmi.uni-passau.de).   It contains a variety of graph and tree drawing algorithms and an interface to support user-specific extensions written in C.   See Section gif for more details on GraphEd and other graph drawing systems.

Combinatorica [Ski90] provides Mathematica implementations    of several tree drawing algorithms, including radial and rooted embeddings. See Section gif for further information on Combinatorica.

Notes: The best reference available on graph drawing is the annotated bibliography on graph drawing   algorithms by Giuseppe Di Battista, Peter Eades, and Roberto Tamassia [BETT94], also available via http://www.cs.brown.edu/ tex2html_wrap_inline29175 rt.

Heuristics for tree layout have been studied by several researchers [RT81, Vau80, WS79], although under certain aesthetic criteria the problem is NP-complete [SR83].  

Related Problems: Drawing graphs (see page gif), planar drawings (see page gif).    


next up previous contents index CD CD Algorithms
Next: Planarity Detection and Embedding Up: Graph Problems: Polynomial-Time Previous: Drawing Graphs Nicely

Algorithms
Mon Jun 2 23:33:50 EDT 1997