A Framework For The Automated Drawing: Structure Diagrams Data
A Framework For The Automated Drawing: Structure Diagrams Data
Abstract-Data structure diagrams are two-dimensional figures made Debugging: In debugging, pictorial representations of
up of lines that aim to pictorially indicate the interrelatiomM
data often make it easier to locate problems and reasons
elements of a data structure. This paper collects the various ru
factors of aesthetics that go into the way we draw data struct for them [25], [34].
grams. We formulate the various subjective factors into computable Program Understanding: Dynamic properties of pro-
objectives and numeric parameters. These are dis grams may be understood through animated diagrams in
number of data structure drawings as found in var animation systems [22], [lo], [ 121, [311. They pictorially
reveal that the rules used have not reached a level
display the contents of interesting variables and update
pared to the relevant rules in engineering graphics. We also outline fhe
internal architecture of a (sub)system that we are building that helps the display as the values change.
draw data structure diagrams. Program Design: During the exploratory period that
precedes detailing the chosen design, people draw pic-
Index Terms-Aesthetics, data structure diagrams, documentation tures of the data structures they are considering, and var-
systems, line drawings, visual debugging.
ious other diagrams that capture the architecture of the
1. INTRODUCTION system. [32] is a book on such diagrams and their con-
ventions.
A picture is worth a thousand words.
Program Visualization is an emerging area [2 11, [28],
(cr)
[Reingold and Hansen 19831 [Standish 19831
Y-J
[Standish19831
Fig. 1 . Examples of diagrams.
(d) (e)
Fig. 2. Different applications need the diagrams to be drawn differently.
Fig. 3. Traditional way of drawing is also important in understanding
diagrams.
on. This problem does not disappear with modern pro-
gramming languages supporting abstract data types either those in the graph theory area draw edges as curves or
WI. straight lines, and nodes as circles or ellipses.
Another reason for the difficulty is that aesthetics is a Aesthetic rules exist in drawing diagrams [34], [52]. To
highly subjective matter. People with different education reduce the visual complexity of a diagram, for example,
levels and cultural backgrounds have different aesthetic good diagrams are typically drawn with few edge cross-
tastes. Researchers in VLSI, for example, draw graphs ings and geometrically short paths. People use such rules,
using boxes and straight or angular lines (Fig. 3) while perhaps unconsciously, to guide and simplify the drawing
DING AND MATETI: DRAWING DATA STRUCTURE DIAGRAMS 545
and the process. Finding these rules and coding them will
make it possible to build a system to automatically draw 0
(in most cases) pleasing pictures.
In this paper, we study issues relating to the automation
of the process of drawing data structure diagrams. We
contribute a framework in which different tastes of what
makes a diagram look good, etc. can be discussed. We
formulated some commonly-used rules which are ob-
Fig. 4. Samples of figure elements.
tained by examining diagrams in many textbooks on data
structures, computer programming, and algorithm design.
connecting arc
We also examine the feasibility of implementations based
I
on these rules.
11. TERMINOLOGY
A data structure diagram (DSD) is a pictorial represen-
tation of the underlying data structure. Just as sentences
of a language can be studied at three levels-words, syn-
tax (grammar), and semantics-we can study diagrams at
three corresponding levels: figure elements, figure ob-
jects, and meaningful diagrams. The terminology that we (a) ib)
need to discuss these matters is still evolving. We offer Fig. 5 . The definition of turns: (a) smooth turn: (b) sharp turns
the following as strictly tentative suggestions for the pur-
poses of this paper. figure elements. For example, a hierarchical structure is
represented by a tree or a layered graph, a ring buffer is
A . Figure Elements represented by a ring of boxes, a linked list is represented
AJigure element is a member of a small set of geomet- by a linked list of boxes, etc.
rically defined open and closed curves. Some commonly The intended semantics of a diagram dictates the
used figure elements are shown in Fig. 4.Figure elements “look” of a diagram. The way we draw a pointer, its
correspond to words in languages, but they are two-di- origin, and target objects conveys considerable meaning.
mensional objects. They represent the smallest semanti- The traditional way of drawing is also important. For ex-
cally meaningful elements in a display of data structures. ample, a tree drawn to satisfy certain unusual require-
An arrow, for example, consists of two geometrical enti- ments may look quite different and be hard to recognize
ties: head and tail. It semantically represents a pointer. Its (Fig. 3).
tail (or head) alone does not represent the semantics of a
pointer. Thus, an arrow is a figure element whereas its C. Other Terms
head or tail, by themselves, are not. Conceptually, a fig- By the term “drawing a diagram,” we refer to the pro-
ure element is an abstract object that captures certain at- cess by which the figure elements chosen for the data ele-
tributes of the elements of a diagram. No rigid notions of ment are laid out to visualize the meaning of the data
dimensions, geometrical shapes, color or fill-texture are structure. “Automated drawing” implies that the process
associated with it. Attributes are such things as content, of drawing, sometimes guided by the user, is essentially
label, and descriptions of how the content is to be dis- done by the system. Legalistically speaking, any diagram
played. can be generated automatically if we ignore aesthetics.
But by “automated drawing” in this paper, we always
B. Semantics of a DSD mean automated drawing of nice diagrams, which is an-
While words in a language may mean what we choose other story.
them to mean, diagrams do not have that liberty. They A number of our rules regarding aesthetics deal with
have to corroborate with the real objects they are depict- the way arrows and edges are drawn. A point on a curve
ing through shape resemblance, action simulation, ab- is called a break point if the derivative of the curve is not
stract extension, etc. Traditional values must also be re- continuous at that point. A turn consists of three (possibly
spected. empty) parts: two straight line segments and a connecting
Figure elements indicate semantics. For example, a arc whose tangents at its two ending points are colinear
square or a circle may represent a node, an ellipse a pro- with its two sides. A smooth turn has no break points; an
cedure, an edge a binary relation, an arrow a pointer, etc. angular turn does. The turn angle is defined as 1 a - 01,
Semantics so indicated is achieved through symbolisms. where a and 0 are the angles that the sides of the turn
The semantics of figure elements are affected by so-called make (counterclockwise) with the x-axis (Fig. 5). We use
visual vocabulary [35]. Bertin [5] described six visual vo- the terms angular/smooth edge and arrow analogously.
cabulary: size, direction, texture, form, and color. An- When the sides are missing, we draw tangents at the end
other indication of semantics comes from the layout of points of the connecting arc and use them as the sides.
546 IEEE TRANSACTIONS ON SOFTWARE ENGINEERING. VOL. 16. NO. 5. MAY 1990
(a) (b)
Fig. 6 . A comparison of the recognizability of the same diagram drawn in
different ways.
The origin of an arrow is the far end of its tail, and its
target is the sharp point of its arrow head. Analogously,
we refer to the origin figure element and target figure ele-
ments of an arrow as the figure elements that the arrow
connects. If two figure elements are connected by an (un-
directed) edge, then either can be called origin or target
figure element.
l l lil
cally. For example, the structure regularity in G ( V , E )
defined in Fig. 6 can be expressed as:
+
Vi: V(edge ( i , ( i 1 ) mod 12) E E &
edge ( i , ( i - 1 ) mod 12) E E &
edge ( i ,( i + 4 ) mod 12) E E &
edge(i,(i + 5 ) m o d 1 2 ) ~ E &
edge ( i ,( i + 7 ) mod 12) E E &
i, i+ 1 mod 12,
i , i - 1 mod 12,
+
i , i 4 mod 12,
+
i , i 5 mod 12,
(d) +
i , i 7 mod 12,
Fig. 8 . Some examples of high misunderstanding possibility diagrams: (a) i, i+ 8 mod 12
a chain is drawn like a binary tree; (b) the node represented by a box
could be misunderstood as a special node; (c) too closely drawn arrows To visualize what regularity there is, we first need to
could cheat our eyes; (d) two diagrams are drawn together which could
be misunderstood as one diagram. discover it from the underlying data structure. It is usually
very difficult for an algorithm to discover it without being
given some sort of hints. Then we need to find an appro-
cause the origin and destination of a straight line are more priate way to present the regularity. This is achieved by
direct than those of curves (Fig. 7). using regular polygons or drawing the diagram in a sys-
b) Semantic Recognizability is the ease with which the tematic way: to place the nodes evenly along a circle, to
interconnection patterns among figure elements of a dia- draw the (sub)diagram symmetrically, etc. Although this
gram are visually recognized. Semantic recognizability is is not as difficult as the first step, we must be careful since
more important than the physical recognizability. The regularity can be represented in different ways (Fig. 3).
physical recognizability affects the semantic recogniz- A regular diagram is more beautiful when its figure ele-
ability somewhat, but the layout of figure elements affects ments are well-organized than when drawn randomly (Fig.
it the most (Fig. 6). 6 ) . Some diagrams are drawn in such a pleasing way that
3) Geometrical Complexity: The first impression that regularity is present “everywhere.” For example, Fig. 9
a diagram makes is a geometrical one: the simpler it looks, [23], [24] has isosceles triangles: (1, 2, 6 ) , ( 1, 6, 5 ) , (2,
the simpler its components are geometrically, the easier 3, 6 ) , ( 3 , 6, 4), ( 6 , 4, 5); parallelograms: ( 1 , 2, 3, 6 ) ,
it can be understood. Factors affecting the geometrical (1, 2, 4, 5 ) , ( 2 , 6 , 4, 3), ( 3 , 4, 5, 6 ) ; trapezoid: (2, 3,
complexity include the number of edges and nodes, the 4, 5 ) .
lengths of edges, and the sizes of nodes.
C. Symmetry
B. Regularity Symmetry is the correspondence in size, form, shape,
Regularity is an important feature of data structures and and arrangement of figure elements on opposite sides of
their displays. There are two types of regularity: structure a plane, line, or point. It is also a kind of regularity (the
regularity and display regularity. The structure regularity regularity of form or arrangement with corresponding
manifests in the connections of a subset of data ele- parts). Like regularity discussed above, it too conveys in-
ments of a data structure by being expressible in a math- formation more quickly, and makes displays more beau-
ematical way. Each element of this subset is connected to tiful.
others in the subset by the connections defined by an
expression. The display regularity is the visualization of D. Consistency
the structure regularity. Regularity plays a very important Consistency means that all figure objects which have
role in improving the readability of complicated diagrams the same connectivity and semantics and geometrical
because regular interconnections are easy to recognize and structure are drawn in the same way. In Fig. 10, for ex-
remember. For example, it is easy to tell which node is ample, each node consists of figure elements for fields
connected to which in Fig. 6(a) compared to Fig. 6(b). LLink, Info, and RLink and figure elements for pointers
Display regularity requires that figure objects be sys- LLink and RLink. All the figure elements for LLink’s
tematically arranged by certain patterns such that the un- in Fig. 10 have the same meaning (they all are left point-
derlying structure regularity can be formulated geometri- ers) and geometrical structure (they are all drawn as ar-
548 IEEE TRANSACTIONS ON SOFTWARE ENGINEERING. VOL. 16. NO. 5 . MAY 1990
-
A XI xz 4
-
:I
sections should be minimized. The length of edges should
be minimized. The number of turns should be minimized.
B. Factors
1 ) Thickness of Lines: The range of thicknesses for
lines (of edges, arrow, or node boundaries) is influenced
by many considerations. It is, for example, not reasonable
to choose one inch thick lines for just making a diagram
on 8” X 11” paper, while we may have to use that thick-
ness in making a huge poster. In this sense, line thickness
Fig. 12. Line separation is affected by its surrounding points.
depends on the size of the diagram.
Line thickness is also a function of viewing distance,
the distance between the eyes of the viewer and the dia-
nodes represent rules in AI. If no special meaning is im- gram. In our opinion, viewing distance affects line thick-
plied, it is advisable not to use different shapes for the ness more directly than the diagram size does. No matter
same kind of nodes. how far or close we are to the diagram, the viewing angle
should be kept the same. If we define the area in which
I. Traditional Ways of Drawing objects can be clearly sensed without intentionally mov-
People understand diagrams better when diagrams are ing our eyeballs as the “sensing area,” then we find that
drawn in a familiar way. The familiar ways are affected size of diagram affects the choice of line thickness only
by the traditional ways of drawing. So sticking to the tra- when the diagram is within the sensing area. Within this
ditional ways of drawing will decrease the possibility of sensing area, the smaller the diagram is, the thinner the
being misunderstood (Fig. 3). lines should be. But if the diagram is bigger than the sens-
ing area, then it will only affect line thickness in a mild
IV. AESTHETICOBJECTIVES, FACTORS,AND RULES way.
It is commonly believed that people use certain aes- Line thickness is also affected by its neighbors, more
thetic rules in drawing graphs. They learn these rules by specifically, by the separations of figure elements. This is
experience and use them intuitively. Finding these Ales about as important as the viewing distance. Numerous
and coding them into algorithms is a key step towards the samples [e.g., comparing Fig. 8(a) and 8(b)] suggest that
automated drawing of data structures. We endeavor to the smaller the separations, the thinner the lines should
formulate rules of drawing that yield diagrams perceived be for the sake of both aesthetics and easy recognizability.
as “good” according to the criteria discussed in Section Finally, since the eye cannot distinguish tiny variations
111. Doubtless they need to evolve. As the rules now stand, in line thickness, and for the sake of figure element con-
our rules not only yield pathological cases but conflict sistency, line thickness should be chosen from a small set
often. In Section V, we suggest ways of arriving at ac- of discrete values. On the other hand, we often use thicker
ceptable compromises algorithmically. than normal lines to show emphasis.
These “rules” are divided into three categories: rules, 2) Size and Shape of Arrow Heads: For the same rea-
factors, and objectives. A rule is informally defined as the sons given above, the size of the arrow heads is affected
way in which figure elements are expected to be arranged by the sizes of diagrams, the viewing distance, the sepa-
to meet certain aesthetic requirements. Examples of rules ration of neighboring figure elements, and consistency.
include “no two diagrams should overlap,” or that Also, we find that an arrow head is more pleasing to the
“edges in a tree are drawn as straight lines or arrows.” eye when the ratio of its height (the distance from the tip
A factor describes a numerical range for a certain variable to the base) to the base is close to the golden ratio,
whose value makes a critical difference in the appearance 1.61803. (See [15] for a related discussion.)
of the diagram. For example, two related edges should be 3) Turns: If the distance between two adjacent turns is
neither too far or too close to each other. An objective small and the sides other than the one between the two
describes the goals we would like to achieve such as turn points are long, both turn angles should be as small
“regularity of structure should be apparent,” or that as possible (Fig. 13). The adjacent turn angles should be
“symmetrical figure elements should be positioned sym- about the same (Fig. 14).
metrically.” Objectives do not say how the goals are 4) Separation: Let us first make the notion of separa-
achieved. tion (Section 111-G) precise. The constant CY appears fre-
quently in the factors below. A proper value for it is hard
A. Objectives to pin down, but it is influenced mainly by the distance
Regularity of structure should be apparent. Figure ele- between the eyes and object, and secondarily by the res-
ments should be drawn consistently. Symmetrical figure olution of the display medium, and the nature of the dia-
550
-
I
c
IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, VOL. 16, NO. 5, MAY 1990
(a) (b)
Fig. 13. (a) Large turn angles look bad. (b) Small turn angles look good.
I \
\
Fig. 14. Good: the turn angles are kept the same. (b) Not too bad: turn Fig. 15. The definition of line separation.
angles are slightly different. (c) Bad: turn angles differ too much.
11
- I
W
Fig. 18. 1231
(a) (b)
Fig. 19. Drawing multiple edges.
Fig. 17. [43]
6
does not cross other nodes. Otherwise, they are drawn as
orthogonal edges or arrows (Figs. 16 and 17).
Short rectangular edges are drawn as curves (Fig. 10).
Edges in circular diagrams are drawn as straight lines
or arrows if they do not cross or very close to other nodes.
Or otherwise, they are drawn as arcs or curves [Fig. 18
edge (2, 611.
Arrows between adjacent nodes in a double link list are
Fig. 20. [23]
drawn as curve arrows (Fig. 10).
b) Drawing Multiple Edges: If the number of edges
between two nodes is even and the origin and target nodes '
are circles or ellipses, then edges are so drawn that all arc
centers are on the line which is perpendicular and passes
the center of the line connecting the centers of the two
nodes (Fig. 19). If the number is two, one of the edges
I ( Jl
could be drawn as a straight line. The straight edge is Fig. 21. [43]
sometimes used to keep consistency among other
edges(Fig. 20).
If the number of edges is odd and the origin and target
nodes are circles, then one of these edges is drawn as a
straight edge, and the others are drawn as above (Fig. 19).
Two long edges are drawn along the same path (Fig.
21). I
3) Pointers: I
a) Origins: Pointers whose origin nodes are boxes Fig. 22. The definition of the center line
should originate from a point on the center line (Figs. 22
and 16). Pointers whose origin nodes are circles or el-
lipses should originate from the border of the node in such origin node is a diamond usually originate from the dia-
a way that the tangent of the edge, at the point of depar- mond's comer (Fig. 24).
tufe, passes through the center (Fig. 18). Pointers whose b) Destinations: If the target node is a circle or el-
origin nodes are boxes filled with text should originate at lipse, pointers should point to the nearest point on the
the center of the origin side (Fig. 23). Pointers whose circle in such a way that its tangent at the border passes
552 IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, VOL. 16. NO. 5. MAY 1990
Binary tree
(Fig. 16). If the origin and target nodes are boxes and the mediate branches, if there are too many branches (Fig.
centers of the origin and target sides are on the same hor- 25), by omitting the intermediate levels, if there are too
izontal or vertical line which does cross other nodes or if many levels (Fig. 26).
the centers are not on the same horizontal or vertical line, a ) Binary Trees: Nodes at the same level should lie
then i) if the arrow is composed of strictly horizontal and/ on a straight line, and straight lines defining the levels
or vertical lines only then the arrow should point to the should be parallel. A left son should be positioned to the
center of the target side (Fig. 17), ii) if the arrow is left of its father and a right to the right. A father should
curved, then the arrow should point to one of the target be centered over its sons [52], [42]. Levels should be
side ends (Fig. 10). equidistant. Higher levels are drawn below lower levels.
If the target node is a diamond, then the destination b) Ordinary Trees: Nodes at the same level of the
should be one of the diamond comers (Fig. 24). tree should lie along a straight lines, and straight lines
4) Turns: When nodes other than boxes are present, a defining the levels should be parallel. A father should be
90” turn can be replaced by two smaller turns. These two centered over its sons.
turns should be as far as possible, while not getting too c) B-Trees are drawn in the same way as that of or-
close to other figure elements. dinary trees except that arrows originate from beside or
Consecutive turns that are close together should use as between elements in nodes (Fig. 27).
small angles of turn as possible (Fig. 13). d) Quasi-Tree is a diagram containing one or more
5) Repetitive Structures: The following structures are trees as subdiagrams (Fig. 28). A chosen tree subdiagram
called repetitive structures for the obvious reason that their is drawn as an ordinary tree with the rest of edges being
diagrams are composed of repetitions of figure objects drawn curved usually with a different shape or thickness
representing the elements: arrays, trees, stacks, queues, (Fig. 28).
rings, and linked lists. e) Heaps are visualized as binary trees.
Abbreviation of repetitive structures is an important is- 7) Miscellaneous Data Types:
sue. When there is not enough space to put all figure ele- a ) Scalars: Strings, integers, reals, booleans, char-
ments in, or some of the figure elements are not important acters, enumerated types are among the most common
to the user, the structures can be abbreviated by the fol- scalar types. They are “drawn” showing their values,
lowing rules: a) If it is a finite repetition, the figure ob- with or without enclosing boxes (Fig. 29).
jects from the third to the last second one in the repetition b) Records: A record is drawn as a horizontal or ver-
series could be omitted. b) If it is infinite, the figure ob- tical stack of rectangles, each of which corresponds to one
DING A N D MATETI: DRAWING DATA STRUCTURE DIAGRAMS 553
a:3
b: '@
ca: -2
cb: This is a test
internalREC: cc: T R h
- 1 I
(a) (b)
Fig. 3 1. Multidimensional arrays
V . AUTOMATION CONSIDERATIONS
Previous efforts in drawing systems can be categorized
as:
Those that concentrate on building a system to au-
tomatically draw diagrams [17], [37], [381, [lo], [401,
[34]. Due to a lack of an appropriate theory and the dif-
ficulties in drawing nice diagrams automatically, aesthetic
issues were not addressed systematically in these systems.
Those that concentrate on automated drawing of dia-
grams for specific classes of data structures [20], [ 121,
IThis is a test 1 [52], [42], [3]. Efforts were made in both aesthetics and
SlWNG ENUMERAlED PROCEDURE
automation issues, but they are typically restricted to a
Fig. 29. [38] small range of data structures such as binary trees.
Those that concentrate on a particular drawing strat-
egy [46], 141, [30], [ 161. These strategies have the poten-
of its fields. If the field is also a record, then it is recur- tial to be incorporated in the systems (like those listed
sively drawn as a record (Fig. 30). above) to achieve our goals.
c) Arrays: One-dimensional arrays are drawn as a In our framework, rules and factors are explicitly rep-
vertical or horizontal stack of boxes. Two-dimensional ar- resented while objectives are implicit in the way the rules
rays are drawn as arrays of boxes [Fig. 31(a)]. Three- are weighted and applied by the driver (Fig. 32). The da-
dimensional arrays are drawn as arrays of two-dimen- tabase, shown in the dashed box, is the result of combin-
sional arrays [Fig. 31(b)]. Arrays of n dimensions, n > ing the builtin rules and factors, such as those discussed
3, are drawn as linear arrays of ( n - 1 )-dimensions. in the previous section, with those contributed by the user.
d ) Linear Lists are drawn horizontally or vertically, When a data structure is being diagrammed, the work area
with arrows originating from the center line and pointing consists of three parts: 1) a (partially-constructed) repre-
to the center of target side (Fig. 16). sentation of the pictorial view of the data structure, 2) a
e) Doubly Linked Li;ts are drawn horizontally or ver- representation of the abstraction of the data structure con-
tically, with arrows originating from the center line and structed from its memory image, and 3) a subset of the
pointing to the nearest corner of the target box (Fig. 10). data base of rules and factors that the driver deemed rel-
f) Rings are drawn as circles of boxes. evant and cached for the data structure.
g) Stacks are drawn as a one-dimensional array, with
or without an arrow or number indicating the top element. A . Memory Image to Abstractions
h) Queues are drawn either as 1) a one-dimensional In this subsection, we briefly describe a phase of pro-
array, or as 2) a ring. Arrows or numbers indicate the cessing that occurs prior to any attempt at drawing a dia-
head and tail of the queue. gram. Where and how do we get the contents of the data
i) Hash Tables: Chained hash tables are drawn as a structure that we are drawing? The drawing system de-
set of linear lists connected by a head array (Fig. 16). scribed in this paper is intended as a component in de-
Other hash tables are drawn as one-dimensional arrays bugging systems as well as in documentation systems. In
where elements receiving the same hashing addresses are a debugging system, the contents are retrieved from the
connected by arrows [Fig. 2(e)]. address space of the program being debugged.
554 IEEE TRANSACTIONS ON SOFTWARE ENGINEERING. VOL. 16. NO. 5. MAY 1990
r
ferred points. Based on this observation, a badness func-
tion may look like: menting systems. In a debugging system, diagram draw-
ing is on-line and interactive. Some systems of this kind
0,x + K, ifa Ix Id are [17], [38], [40], [34], [ 2 5 ] . Many diagrams are used
only for the purpose of debugging. The user can only wait
badness(x) =
09 + K~ ifd Ix 5 c
for rather short period of time to compute the diagrams.
09 + K~ i f c Ix 5 e A perfect but very time consuming picture is not desir-
04x + K4 if e Ix 5 b able. In systems such as this, the optimal solution is at-
tempted only if it does not take a long time. Otherwise,
-
where a , b , * * , e are points, Oi are the slopes, and K~ an approximate solution is generated.
are the offsets (Fig. 34). In contrast, in documentation preparation systems, dia-
b) Badness of a Diagram Due to Edge Intersec- grams are no longer the intermediate products and the re-
tions: It is ideal to have no intersections. Otherwise, bad- quirements for the goodness are much higher than those
ness is proportional to the number of intersections. in debuggers. Users now wish the diagram to be drawn as
556 I E E E TRANSACTIONS O N SOFTWARE E N G I N E E R I N G . VOL. 16. NO. 5 , MAY IYYO
perfectly as possible. The computing time, while still not We also formulated how the aesthetic rules and objec-
infinite, is not very limited here. tives can be represented in a system. We are in the process
There are numerous optimization problems in drawing of building a (sub) system based on these ideas.
diagrams such as the minimization of the number of in-
tersections, of the number of turns, of the length of edges,
etc. Most of these optimization problems have exponen- REFERENCES
tial complexity. Since time is a very important factor in A. V. Aho, J. E. Hopcroft, and J . D. Ullman, The Design and Anal-
drawing diagrams, most optimization problems can only ysis of Computer Algorithms. Reading, MA: Addison-Wesley, 1974.
J . Amstein, The International Dictionary of Graphic Symbols. Lon-
be solved approximately. Another strategy is to use mul- don: Century, 1986.
tiple steps in drawings, i.e., the diagram is drawn at dif- M. Augenstein and Y. Langsam, “Graphic displays of data structures
ferent levels of badness depending on the available amount on the IBM PC,” SIGCES Bull., vol. 18, no. I , pp. 73-81. Feb.
1986.
of time. The system tries its best to draw it within the R . I . Becker and S . R. Schach, “Drawing labeled directed binary
specified timespan. If the user is not happy with the re- graphs on a grid,” in Proc. ACM 20th Southeast Regional Conf.,
sult, more’time is then given and the system further re- Knoxville, TN, 1982.
J . Bertin, Semiologie Graphique: Les Diagrammers, Les Reseaux, Les
fines the drawing. Cartes. Paris: Mouton, 1967.
H.-D. Bocker, G. Fisher, and H. Nieper, “The enhancement of un-
F. Customization derstanding through visual representation,” in CHI ’86 Proc., Apr.
1986, pp. 44-50.
Customization is always needed to the diagrams gen- H. D. Boecker and H. Nieper, “Making the invisible visible: Tools
erated by the system. The reasons for the need are nu- for exploratory programming,” in Proc. First Pan Pacijic Computer
Conf., Australian Comput. Soc., Melboune, Australia, Sept. 1985.
merous. Users have their own preference and aesthetic P. R . Bono, “A survey of graphics standards and their role in infor-
tastes. One of the typical examples for customization is mation interchange,” Computer, vol. 18, no. 10, pp. 63-75, Oct.
the orientation of one dimensional arrays. Some users like 1985.
A. Borning, “The programming language aspects of ThingLab. a
them to be drawn vertically, while others horizontally; constraint-oriented simulated laboratory,” ACM Trans. Program.
some applications need them to be drawn vertically, while Lung. Syst., vol. 3 , no. 4,Oct. 1981.
others horizontally. M. H. Brown and R . Sedgewick, “A system for algorithm anima-
tion,’’ ACM Comput. Graphics, vol. 18, no. 3, pp. 177-186, July
We also find that different communities of computer 1984.
science have different preferences. Lispers, for example, S.-K. Chang, Ed., Visual Language. New York: Plenum, 1986.
have their “peculiar” way of drawing [12] lists. Users in M. S. Dionne and A. K. Mackworth, “ANTICS: A system for ani-
mating LISP programs,” Comput. Graphics Image Processing, vol.
programming area and researchers in graph theory area 7, pp. 105-119, 1978.
draw graphs in different ways. A programmer likes to S . Feiner, S. Nagy, and A. van Dam, “An experimental system for
draw nodes as a stack of boxes and have the field names creating and presenting interactive graphical documents,” ACM
Trans. Graphics, vol. 1, no. I , pp. 59-77, 1982.
and values expressed explicitly. But graph theorists prefer W. Finzer and L. Gould, “Programming by rehearsal,” Byte, vol. 9,
drawing nodes as circles or ellipses. VLSI researchers like no. 6, pp. 187-210, June 1984.
using straight lines and view the line intersections more J . Gait, “An aspect of aesthetics in human-computer communica-
tions: Pretty windows,” IEEE Trans. Software Eng., vol. SE-11, no.
seriously than do users in other areas. ..
8. DD. 714-717. Aug. 1985.
5.
I
There are several ways to allow users to have their pref- 1161 E. R., Gansner, S. North, and K . P. Vo, “DAG-A program that
erence: draws directed graphs,” Software-Practice and Experience, vol. 18,
no. 11, ..
PP. 1047-1062, Nov. 1988.
The system allows the user to gather his own rules S . L. Getz, G. Kalligiannis, and S . R . Schach, “A very high-level
into a file, and the system will overwrite the correspond- interactive graphical trace for the Pascal heap,” IEEE Trans. Soft-
ing builtin rules. ware Eng., vol. SE-9, no. 2, pp. 179-185, Mar. 1983.
F. E. Giesecke, Engineering Graphics, 4th ed. New York: Mac-
Rules in the system are modifiable by the user. millan 1987.
Most rules have default values or actions which are E. P. Glinert and S . L. Tanimoto, “Pict: An interactive graphical
changeable by users. programming environment,” Computer, vol. 17, no. 11, pp. 7-25,
Nov. 1984.
G. Hain and K. Hain, “A general purpose automatic flowcharter,”
in Proc. Fourth Annu. Meeting UAIDE, New York, Oct. 1965, pp.
VI. CONCLUSION iv- 1-iv- 12.
Data structure diagrams convey technical information. C. F. Herot et a l . , “An integrated environment for program visual-
ization,” in Automated Tools f o r Information Systems Design, H. J .
While subjective preferences may prevail as to how an Schneider and A. I. Wasserman, Eds. Amsterdam, The Nether-
arrow or an array should be drawn, the overall concern lands: North-Holland, 1982, pp. 237-259.
ought to be the clarity with which this information is com- F. R. A. Hopgood, “Computer animation used as a tool in teaching
computer science,” in Proc. I974 IFIP Congr., Applications vol-
municated. Based on some commonly agreed principles, ume, 1974, pp. 889-892.
we have discussed what factors make a diagram look good E. Horowitz and S . Sahni, Fundamentals of Computer Algorithms.
and convey its information easily and consistently. ’ Woodland Hills, CA: Computer Science Press, 1976.
[24] -, Fundamentals of Data Structures. Woodland Hills, CA: Com-
We divided the aspects that govern the drawing of these puter Science Press, 1976.
figures into rules, factors, and objectives. While there are [25] S . Isoda, T. Shimomura, and Y. Ono, “VIPs: A visual debugger,”
some aspects that apply to all diagrams, most of the rules IEEE Software, pp. 8-19, May 1987.
[26] B. W. Kernighan, “PIC-A language for typesetting graphics,” in
and objectives are specific to the abstraction that a data Proc. of the ACM SIGPLAN SIGOA Symp. Text Manipulation, Port-
structure represents. land, OR, 1981, pp. 92-98.
DING A N D MATETI: DRAWING DATA STRUCTURE DIAGRAMS 557
[27] D. E. Knuth, “Computer drawn flowcharters,” Commun. ACM, vol. [47] B. Schneiderman “Direct manipulation: A step beyond programming
6, no. 9 , pp. 555-563, Sept. 1963. languages,” Computer, vol. 16, no. 8, pp. 57-69, Aug. 1983.
[28] D. Kramlich et a l . , “Program visualization: Graphics support for [48] B. Schneiderman, P. Shafer, R. Simon, and L. Weldon, “Display
software development,” in Proc. 20th Design Automation Conf. , strategies for program browsing,” in Proc. Conf. Sofware Mainte-
1983, pp. 143-149. nance, IEEE Comput. Soc., Washington, DC, 1985.
[291 S . Lammers, Programmers at Work. Microsoft Press, 1986. [49] T. A. Standish, Data Structure Techniques. Reading, MA: Addi-
[30] R. J. Lipton, S . C. North, and J. S . Samdberg, “A method for draw- son-Wesley, 1980.
ing graphics,” in Proc. ACM Symp. Computational Geometry, Bal- [50] D. Thalmann, “An interactive data visualization system,’’ Soft-
timore, MD, 1985, pp. 153-160. ware-Practice and Experience, vol. 14, no. 3, pp. 277-290, Mar.
[31] R. L. London and R. A. Duisberg, “Animating programs using 1984.
Smalltalk,” Computer, vol. 18, no. 8, pp. 61-71, Aug. 1985. [51] E. R. Tufte, The Visual Display of Quantitative Information.
[32] J . Martin, Recommended Diagramming Standards for Analysts and Cheshire, CT: Graphics Press, 1983.
Programmers: A Basis for Automarion. Englewood Cliffs, NI: Pren- [52] C. Wetherell and A. Shannon, “Tidy drawings of trees,” IEEE Trans.
tice-Hall, 1987. Sofware Eng., vol. SE-5, pp. 514-520, 1979.
1331 P. Mateti, Visualization of Abstract Data Types, to be published. [53] E. Yarwood, “Toward program illustration,” Univ. Toronto Com-
[34] P. Mateti and G. M. Radack, “Automated drawing of data structure puter Systems Research Group, Rep. CSRG-84, Oct. 1977.
diagrams,” in Proc. 4th Annu. Nat. Con$ Ada Technology, Mar. [54] D. E. Knuth, The TEXbook. Reading, MA: Addison-Wesley, 1984.
1986, pp. 165-172.
[35] G . F. McCleary, Jr., “An effective graphic vocabulary,” IEEE Com-
put. Graphics Applications, pp. 46-53, Mar./Apr. 1983.
[36] F. S . , Montalvo, “Diagram understanding: Associating symbolic de-
scriptions with images,” in Proc. Second IEEE Workshop Visual Chen Ding received the B.Sc. degree in computer
Languages, Dallas, TX, June 1986. science from the University of Science and Tech-
[37] B. A. Myers, R. Chandhok, and A. Sareen, “Automatic data visu- nology of China, Hefei, Anhui, People’s Repub-
alization for novice Pascal programmers,” in Proc. 1988 IEEE Work- lic of China, in 1984.
shop Visual Languages, Pittsburgh, PA, Oct. 1988, pp. 192-198. He received a fellowship from K. C. Wong Ed-
[38] B. A. Myers, “Incense: A system for displaying data structures,” ucation Foundation, Hong Kong, in 1986 and is
Comput. Graphics, vol. 17, no. 3, pp. 115-125, July 1983. currently completing his Ph.D. dissertation at
[39] W. M. Newman, “A graphical language for display programming,” Case Western Reserve University, Cleveland, OH.
in Proc. Int. Conputer Graphics Symp., Brunel Univ., Uxbridge, En- His research interests include user interfaces, pro-
gland, Aug. 1968. gram visualization, and computer animation.
[40] F. J . Ojeda, “DDS: A subsystem for displaying data structures for
interactive debugging,” M.S. thesis, Dep. Comput. Eng. Sci., Case
Western Reserve Univ., Aug. 1985.
[41] M. C. Pong and N. Ng, “PIGS-A system for programming with
interactive graphical support,” Software-Practice and Experience, Prabhaker Mateti (S’75-M’76) received the
vol. 13, no. 9 , pp. 847-855, Sept. 1983. Bachelor’s degree in electrical engineering from
1421 E. M. Reingold and J. S . Tilford, “Tidier drawings of trees,” IEEE Regional Engineering College at Warangal in
Trans. Software Eng., vol. SE-7, pp. 223-228, 1981. 1969, the M. Tech degree in electrical engineer-
[43] E. M. Reingold and W. J. Hansen, Data Structures. Boston, MA: ing from Indian Institute of Technology at Kanpur
Little Brown, 1983. in 1972, and the Ph.D. degree in computer sci-
[44] S . P. Reiss, “PECAN: Program development systems that support ence from the University of Illinois at Urbana-
multiple views,” IEEE Trans. Sofware Eng., vol. SE-11, no. 3, pp. Champaign in 1976.
276-285, Mar. 1985. He is an Associate Professor of Computer Sci-
[45] -, “Graphical program development with PECAN program devel- ence and Engineering at Wright State University,
opment systems,” in Proc. ACM SIGSOFT/SIGPLAN Software En- Dayton, OH. His research interests include pro-
gineering Symp. Practical Sojiware Development Environments, gramming language design, formal aspects of software engineering, graph
Pittsburgh, PA, Apr. 1984, pp. 30-48. algorithms, and man-machine interaction. His recent work is aimed toward
[46] M. I. Shamos and D. Hoey, “Geometric intersection problems,” in constructing a computer-aided environment for the precision design of soft-
Proc. 17th Annu. Symp. Foundarions of Compurer Science, Houston, ware.
TX, 1976, pp. 208-215. Dr. Mateti is a member of the IEEE Computer Society.