We consider a graph that changes over time. Its vertices enter the graph one after the other and persist in the graph for a fixed amount of time, called the window size. We call such a dynamic graph a graph story. More formally, let be the set of vertices of a graph . Each vertex is equipped with a label , which specifies the time instant at which appears in the graph. The labeling is a bijective function specifying a total ordering for . At any time , the graph is the subgraph of induced by the set of vertices . We denote a graph story by .
We are interested in devising an algorithm for visualizing graph stories. The input of the algorithm is an entire graph story and the output is what we call a drawing story. A drawing story is a sequence of drawings of the graphs . The typical graph drawing conventions can be applied to a drawing story. E.g., a drawing story is planar, straight-line, or on the grid if all its drawings are planar, straight-line, or on the grid, respectively.
A trivial way for constructing a drawing story would be to first produce a drawing of and then to obtain a drawing of , for each time , by filtering out vertices and edges that do not belong to . However, if the number of vertices of is much larger than , this strategy might produce unnecessarily large drawings. Ideally, the area of the drawing of each graph should be a (polynomial) function of , rather than a function of the size of the entire graph.
In this paper we show that the graph stories of paths and trees can be drawn on a and on an grid, respectively, so that all the drawings of the story are straight-line and planar, and so that vertices do not change their position during the drawing story. Further, we show that there exist graph stories of planar graphs that cannot be drawn within an area that is only a function of , if planarity is required and vertices are not allowed to change their position during the drawing story.
The visualization of dynamic graphs is a classic research topic in graph drawing. In what follows we compare our model and results with the literature. We can broadly classify the different approaches in terms of the following features. (i) The objects that appear and disappear over time can be vertices or edges. (ii) The lifetime of the objects may be fixed or variable. (iii) The story may be entirely known in advance (off-line model) or not (on-line model). In this paper, the considered objects are vertices, the lifetime is fixed and the model is off-line.
A considerable amount of the literature on the theoretical aspects of dynamic graphs focuses on trees. In , the objects are edges, the lifetime is fixed, and the model is on-line; an algorithm is shown for drawing a tree in area, under the assumption that the edges arrive in the order of a Eulerian tour of the tree. In , the objects are vertices, the lifetime is fixed, the model is off-line (namely, the sequence of vertices is known in advance, up to a certain threshold ), and the vertices can move. A bound in terms of and is given on the total amount of movement of the vertices. In , each subgraph of the story is given (each subgraph is a tree, whereas the entire graph may be arbitrary), each object can have an arbitrary lifetime, the model is off-line, and the vertices can move. Aesthetic criteria as in the classical Reingold-Tilford algorithm  are pursued.
Other contributions consider more general types of graphs. In , the objects are edges, which enter the drawing and never leave it, the model is on-line, the considered graphs are outerplanar, and the vertices are allowed to move by a polylogarithmic distance. In , the objects are edges, the lifetime is fixed, and the model is off-line; NP-completeness is shown for the problem of computing planar topological drawings of the graphs in the story; other results for the topological setting are presented in [1, 20]. Further related results appear in [6, 10, 11, 15, 17, 19]; in particular, geometric simultaneous embeddings [4, 5] are closely related to the setting we consider in this paper. Contributions focused on the information-visualization aspects of dynamic graphs are surveyed in ; further, a survey on temporal graph problems appears in .
Missing proofs can be found in the full version of the paper.
In this section, we present definitions and preliminaries.
Graphs and drawings.
We denote the set of vertices and edges of a graph by and , respectively. A drawing of maps each vertex in to a distinct point in the plane and each edge in to Jordan arc between its end-points. A drawing is straight-line if each arc is a straight-line segment, it is planar if no two arcs intersect, except at a common endpoint, and it is on the grid (or, a grid drawing) if each vertex is mapped to a point with integer coordinates.
Rooted ordered forests and their drawings.
A rooted tree is a tree with one distinguished vertex, called root and denoted by . We denote by the subtree of rooted at a node .
A rooted ordered tree is a rooted tree such that, for each vertex , a left-to-right (linear) order of the children of is specified. A sequence of rooted ordered trees is a rooted ordered forest.
A strictly-upward drawing of a rooted tree is such that each edge is represented by a curve monotonically increasing in the -direction from a vertex to its parent. A strictly-upward drawing of a rooted forest is such that the drawing of each tree in is strictly-upward. A strictly-upward drawing of an ordered tree is order-preserving if, for each vertex , the left-to-right order of the edges from to its children in the drawing is the same as the order associated with in . A strictly-upward drawing of a rooted ordered forest is order-preserving if the drawing of each tree is order-preserving. The definitions of (order-preserving) strictly-leftward, strictly-downward, and strictly-rightward drawings of (ordered) rooted trees and forests are similar.
. Given two points and in , we denote by the closed straight-line segment connecting and . The width and height of a grid are and , respectively. A grid drawing of a graph lies on a grid if is enclosed by the bounding box of some grid of width and height , and lies on the grid if is enclosed by the bounding box of the grid .
A graph story is naturally associated with a sequence ; for any , the graph is the subgraph of induced by the set of vertices . Clearly, . Note that are subgraphs of and are subgraphs of , while each of and has a vertex that the other graph does not have, for . A graph story in which is a planar graph, a path, or a tree is a planar graph story, a path story, or a tree story, respectively.
A drawing story for is a sequence of drawings such that, for every : (i) is a drawing of , (ii) a vertex is drawn at the same position in all the ’s such that , and (iii) an edge is represented by the same curve in all the ’s such that . The above definition implies that the drawings are the restrictions of to the vertices and edges of , respectively, and that the drawings are the restrictions of to the vertices and edges of , respectively. Hence, an algorithm that constructs a drawing story only has to specify the drawings .
We only consider drawing stories that are planar, straight-line, and on the grid. Storing each drawing in would require space in total. However, since each vertex has the same position in all the drawings where it appears, since edges are straight-line segments, and since any two consecutive graphs in a graph story differ by vertices, we can encode in total space.
Let be a straight-line drawing story of a graph story and let be a subgraph of (possibly ). The drawing of induced by is the straight-line drawing of in which each vertex has the same position as in every drawing where it appears. Note that the drawing of induced by might have crossings even if is planar. For a subset , let be the subgraph of induced by the vertices in and let be the straight-line drawing of induced by .
Given a graph story , we will often consider a partition of into buckets , where . For , the bucket is the set of vertices such that . Note that all buckets have vertices, except, possibly, for . We have the following useful property.
For any , let . Then is a subgraph of .
3 Planar Graph Stories
In this section we prove a lower bound on the size of any drawing story of a planar graph story. Let . An -vertex nested triangles graph contains the vertices and the edges of the -cycle , for , plus the edges , for . The nested triangles graphs with vertices are -connected and thus they have a unique combinatorial embedding (up to a flip) . We have the following.
Let be a planar graph story such that is an -vertex nested triangles graph and . Then any drawing story of lies on a grid.
In order to prove the statement we show that, for any drawing story of , the straight-line drawing of induced by is planar. Then the statement follows from well-known lower bounds in the literature [8, 12, 13].
Let . Note that, for any , the graph contains the cycles , , and . For any , let and be the subgraphs of induced by and by , respectively, and let and be the drawings of and induced by , respectively.
Since , in order to show that the drawing of induced by is planar, it suffices to show that is planar, for each . We prove this statement by induction on . The induction also proves that the cycle bounds a face of and of .
Suppose first that . Then and the drawing of is planar since is a planar straight-line drawing of and . The -connectivity of and implies that bounds a face of and .
Suppose now that . We show that is planar. By induction, is planar. Thus, we only need to prove that no crossing is introduced by placing the vertices , , and , which belong to and not to , in as they are placed in and by drawing their incident edges as straight-line segments. First, by induction, the cycle bounds a face of and of . Second, the vertices , , and , as well as their incident edges, lie inside such a face in . Namely, , , and lie inside the same face of in , as otherwise the cycle would cross edges of in ; further, the face of in which , , and lie in is incident to all of , , and , as otherwise the edges , , and would cross edges of in ; however, no face of other than the one delimited by is incident to all of , , and . This proves the planarity of . The induction and the proof of the theorem are completed by observing that bounds a face of and .
4 Path Stories
Let be a path story, where . Note that the ordering of given by the path is, in general, different from the ordering given by .
The -buckets of are the sets , with , such that , and , for . Note that each -bucket has vertices, except for and, possibly, the last -bucket; see Fig. 1. The -buckets of are the sets , with , such that . Note that each -bucket has vertices, except possibly for the last -bucket; see Fig. 1. Also, each vertex belongs to exactly one -bucket and to exactly one -bucket.
We now present the following theorem; its proof is similar in spirit to the proof that any two paths admit a simultaneous geometric embedding .
For any path story , it is possible to compute in time a drawing story that is planar, straight-line, and lies on a grid.
Let be the path and let be the number of buckets of . We now order the vertices in each -bucket and in each -bucket; this is done according to the ordering in which the vertices appear in the path . Formally, for , let be a bijective function such that, for any , we have if and only if . Similarly, for , let be a bijective function such that, for any , we have if and only if . We assign the coordinates to the vertices of in as follows. For any vertex of , let and be the -bucket and the -bucket containing , respectively. We place at the point in all the drawings such that belongs to . Also, we draw each edge as a straight-line segment.
We now prove that the constructed drawing story satisfies the properties in the statement. Since -buckets and -buckets have size at most , we have that each drawing lies on the grid. We have the following.
For , the straight-line drawing of is planar. For , the straight-line drawing of is planar.
Finally, the time needed to compute coincides with the time needed to compute the functions and , for each and . This can be done in total time as follows. For , traverse the path from to . When a vertex is considered, the buckets and where should be inserted are determined in time; then is inserted in each of these buckets as the currently last vertex. This process provides each -bucket and each -bucket with the desired orderings and , respectively.
5 Tree Stories
In this section we show how to draw a tree story . Our algorithm partitions into buckets and then partitions the subtrees of induced by each bucket
into two rooted ordered forests. For odd values of, the forests corresponding to are drawn “close” to the -axis, while for even values of , the forests corresponding to are drawn “close” to the -axis. The drawings of these forests need to satisfy strong visibility properties, as edges of might connect vertices in a bucket with the roots of the forests corresponding to the bucket , and vice versa. We now introduce a drawing standard for (static) rooted ordered forests that guarantees these visibility properties.
For a vertex in a drawing , denote by the half-line originating at with slope . Also, consider a horizontal half-line originating at and directed rightward; rotate such a line in clockwise direction around until it overlaps with ; this rotation spans a closed wedge centered at , which we call the -wedge of and denote by . We have the following definition.
Let be a rooted ordered forest, with a total of vertices. A -drawing of is a planar straight-line strictly-upward strictly-leftward order-preserving grid drawing of such that:
lies on the grid;
the roots lie along the segment , in this order from bottom to top, and lies on ;
the vertices of have -coordinates strictly smaller than the vertices of , for ;
for each tree and for each vertex of , let be the children of in left-to-right order; then the vertices of have -coordinates strictly smaller than the vertices of , for ; and
for each vertex of , the wedge does not intersect other than along .
We are going to use the following property.
For each vertex in a -drawing of , the wedge contains the segment in its interior.
We can similarly define -, -, and -drawings; in particular, a drawing of is a -, -, or -drawing if and only if it can be obtained from a -drawing by a clockwise rotation around the origin of the Cartesian axes by , , or , respectively. A property similar to Prop. 3 can be stated for such drawings.
We now present an algorithm, called -Drawer, that constructs a -drawing of . The algorithm -Drawer constructs by induction, primarily, on and, secondarily, on the number of vertices of .
The base case of the algorithm -Drawer happens when (and thus ); then we obtain by placing at . In the first inductive case, we have and ; see Fig. 2. Let be the rooted ordered forest , where are the children of in left-to-right order. Inductively construct a -drawing of . We obtain by placing at and by translating one unit to the right and two units down. In the second inductive case, we have ; see Fig. 3. We inductively construct a -drawing of and a -drawing of the rooted ordered forest . Then, we obtain from and by translating down so that lies two units below the lowest vertex in . We have the following.
The algorithm -Drawer constructs a -drawing of in time.
Algorithms -Drawer, -Drawer, and -Drawer that construct a -drawing, a -drawing, and a -drawing of can be defined analogously.
We now go back to the problem of drawing a tree story . Let . Recall that is partitioned into buckets , where . We now show how to partition the subtrees of induced by each bucket into up to two rooted ordered forests, so that the algorithms -, -, -, and -Drawer can be exploited in order to draw such forests, thus obtaining a drawing story of . We proceed in several phases as follows.
We label each vertex of belonging to a bucket with the label and we remove from all the edges such that . Observe that such edges are not visualized in a drawing story of .
As might be a forest because of the previous edge removal, we add dummy edges to to turn it back into a tree, while ensuring that for every edge of . This is possible due to the following.
Dummy edges can be added to in total time so that becomes a tree and every edge of is such that .
We now root at an arbitrary vertex in . A pertinent component of is a maximal connected component of composed of vertices in the same bucket. We assign a label to a pertinent component if every vertex of belongs to . We now construct the following sets of pertinent components of ; see Fig. 4. The set only contains the pertinent component of the vertex belongs to. For , the set contains every pertinent component of such that (i) does not belong to and (ii) contains a vertex that is adjacent to a vertex belonging to a pertinent component in .
By the construction of the ’s, since for every edge of , and by the rooting of , we have the following simple property.
For every vertex , each child of belongs to either or .
Next, we turn into an ordered tree. Consider any vertex and let be the set belongs to. Then, by Prop. 4, each child of is either in or in . We set the left-to-right order of the children of so that all those in come first, in any order, and all those in come next, in any order.
We now define rooted ordered forests. For with odd, let (resp., ) be the forest containing all the pertinent components such that and such that with (resp., ). Also, for with even, let (resp., ) be the forest containing all the pertinent components such that and such that with (resp., ). We have the following.
Let be a vertex of and be its parent. Let and be the sets containing the pertinent components and belong to, respectively, where or , by Prop. 4. Then the following cases are possible.
If , then and both belong to either , , , or .
If , then is the root of a pertinent component in . Also, either:
is odd, , and ;
is even, , and ;
is odd, , and ; or
is even, , and .
For each pertinent component in any , with and , let be the set belongs to. If , then the root of is , otherwise the root of is the vertex of that is adjacent to a vertex in . Further, the left-to-right order of the children of every vertex of is the one inherited from . Finally, the linear ordering of the pertinent components in is defined as follows. Let and be any two pertinent components in and let and be the sets containing and , respectively. If , then precedes in . If , then follows in . Otherwise ; let be the lowest common ancestor of the roots of and of in . Also, let and be the paths connecting the roots of and of with , respectively. Further, let and be the children of belonging to and to , respectively. Then, precedes in if and only if precedes in the left-to-right order of the children of . We have the following.
Given the sets , the rooted ordered forests , with and , can be computed in total time.
We are now ready to state the following main result.
For any tree story such that has vertices, it is possible to construct in time a drawing story that is planar, straight-line, and lies on an grid.
We construct a planar straight-line drawing story of . We perform Phases 1–5 in order to construct the rooted ordered forests with and