Dynamic Multilevel Graph Visualization
Dynamic Multilevel Graph Visualization
Todd L. Veldhuizen∗
Abstract
We adapt multilevel, force-directed graph layout techniques to vi-
sualizing dynamic graphs in which vertices and edges are added and
removed in an online fashion (i.e., unpredictably). We maintain mul-
tiple levels of coarseness using a dynamic, randomized coarsening al-
gorithm. To ensure the vertices follow smooth trajectories, we employ
dynamics simulation techniques, treating the vertices as point parti-
cles. We simulate fine and coarse levels of the graph simultaneously,
coupling the dynamics of adjacent levels. Projection from coarser to
finer levels is adaptive, with the projection determined by an affine
transformation that evolves alongside the graph layouts. The result is a
dynamic graph visualizer that quickly and smoothly adapts to changes
in a graph.
1 Introduction
Our work is motivated by a need to visualize dynamic graphs, that is, graphs
from which vertices and edges are being added and removed. Applications
include visualizing complex algorithms (our initial motivation), ad hoc wire-
less networks, databases, monitoring distributed systems, realtime perfor-
mance profiling, and so forth. Our design concerns are:
D1. The system should support online revision of the graph, that is, changes
to the graph that are not known in advance. Changes made to the
graph may radically alter its structure.
1
D3. Changes made to the graph should appear immediately, and the layout
should stabilize rapidly after a change.
D4. The system should produce aesthetically pleasing, good quality lay-
outs.
We make two principle contributions:
1. We adapt multilevel force-directed graph layout algorithms [Wal03]
to the problem of dynamic graph layout.
2. We develop and analyze an efficient algorithm for dynamically main-
taining the coarser versions of a graph needed for multilevel layout.
2
Multilevel graph layout algorithms [Wal03, KCH02, HK02, GGK04, HJ04,
FT07a] operate by repeatedly ‘coarsening’ a large graph to obtain a sequence
of graphs G0 , G1 , . . . , Gm , where each Gi+1 has fewer vertices and edges
than Gi , but is structurally similar. For a pair (Gi , Gi+1 ), we refer to Gi
as the finer graph and Gi+1 as the coarser graph. The coarsest graph Gm
is laid out using standard force-directed layout. This layout is interpolated
(projected) to produce an initial layout for the finer graph Gm−1 . Once the
force-directed layout of Gm−1 converges, it is interpolated to provide an
initial layout for Gm−2 , and so forth.
2. How to couple the dynamics of finer and coarser graphs so that ‘layout
advice’ can quickly propagate from coarser to finer graphs.
3
We address the second challenge by using coarse graph vertices as in-
ertial reference frames for vertices in the fine graph (Section 3). The pro-
jection from coarser to finer graphs is given dynamics, and evolves simul-
taneously with the vertex positions, converging to a least-squares fit of the
coarse graph onto the finer graph (Section 3.2.1). We introduce time dila-
tions between coarser and finer graphs, which reduces the problem of the
finer graph reacting to cancel motions of the coarser graph (Section 3.2.2).
1.3 Demonstrations
Accompanying this paper are the following movies.2 All movies are real-
time screen captures on an 8-core Mac. Unless otherwise noted, the movies
use one core and 4th order Runge-Kutta integration.
4
(a) ev1049_cube (b) ev1049_coarsening
5
2 Related work
Graph animation is widely used for exploring and navigating large graphs
(e.g., [HMM00].) There is a vast amount of work in this area, so we focus
on systems that aim to animate changing graphs.
Offline graph animation tools develop an animation from a sequence
of key frames (layouts of static graphs). Such systems find layouts for key
frame graphs, and then interpolate between the key frames in an appropri-
ate way (e.g. [FE02]).
In contrast, our system tackles the problem of online or incremental
graph layout. We use the term online in the sense of online algorithms:
one receives a sequence of requests (in our case, changes to a graph), and
each request must be processed without foreknowledge of future requests.
The key frame approach can be adapted to address the online problem
by computing a new key frame each time a request arrives, and then interpo-
lating to the new key frame. For example, Huang et al [HEW98] developed
a system for browsing large, partially known graphs, where navigation ac-
tions add and remove subgraphs. They use force-directed layout for key
frame graphs, and interpolate between them. A similar approach is used by
Frishman and Tal [FT07b], who use multilevel force-directed layout for key
frames.
Another approach is to take an existing graph layout algorithm and in-
crementalize (or dynamize) it. For example, the Dynagraph system [NW01,
EGK∗ 04] uses an incrementalized version of the batch Sugiyama-Tagawa-
Toda algorithm [STT81].
Our basic approach is to develop an incrementalized version of Wal-
shaw’s multilevel force-directed layout algorithm [Wal03]. We perform a
continuously running force-directed layout. When a graph change request
arrives, the graph is immediately updated. This changes the potential func-
tion, so that the current layout is no longer an equilibrium position. The
layout immediately starts to seek a new equilibrium. If the changes come
rapidly enough, the graph will be in continuous motion. One advantage of
this approach is that changes to the graph are shown immediately, without
delaying to compute a key frame.
3 Layout Dynamics
We use Lagrangian mechanics to derive the equations of motion for the
simulation. Lagrangian mechanics is a bit excessive for a simple springs-and-
6
repulsion graph layout. However, we have found that convergence times
are greatly improved by dynamically adapting the interpolation between
coarser and finer graphs. For this we use generalized forces, which are
easily managed with a Lagrangian approach.
As is conventional, we write ẋi for the velocity of vertex i, and ẍi for its
acceleration. We take all masses to be 1, so that velocity and momentum
are interchangeable.
In addition to the potential energy V (Eqn (1)), we define a kinetic
energy T . For a single graph, this is simply:
X
1 2
T = 2 kẋi k (2)
vi ∈V
7
3.2 Two-level dynamics
We now describe how the dynamics of a graph interacts with its coarser
version. For notational clarity we write y i for the position of the coarse ver-
tex corresponding to vertex i, understanding that each vertex in the coarse
graph may correspond to multiple vertices in the finer graph.3
In Walshaw’s static multilevel layout algorithm [Wal03], each vertex xi
simply uses as its starting position y i , the position of its coarser version. To
adapt this idea to a dynamic setting, we begin by defining the position of xi
to be y i plus some displacement δ i , i.e.,:
xi = δi + y i
However, in practice this does not work as well as one might hope, and
convergence is faster if one performs some scaling from the coarse to fine
graph, for example
xi = δi + ay i
A challenge in doing this is that the appropriate scaling depends on the char-
acteristics of the particular graph. Suppose the coarse graph roughly halves
the number of vertices in the fine graph. If the fine graph is, for example,
a three-dimensional cube arrangement of vertices with 6-neighbours, then
the expansion ratio needed will be ≈ 21/3 or about 1.26; a two-dimensional
√
square arrangement of vertices needs an expansion ratio of ≈ 2 or about
1.41. Since the graph is dynamic, the best expansion ratio can also change
over time. Moreover, the optimal amount of scaling might be different for
each axis, and there might be differences in how the fine and coarse graph
are oriented in space.
Such considerations led us to consider affine transformations from the
coarse to fine graph. We use projections of the form
xi = δ i + αy j + β (5)
8
3.2.1 Frame dynamics
We summarize here the derivation of the time evolution equations for the
affine transformation (α, β). Conceptually, we think of the displacements δi
as “pulling” on the transformation: if all the displacements are to the right,
the transformation will evolve to shift the coarse graph to the right; if they
are all outward, the transformation will expand the projection of the coarse
graph, and so forth. In this way the finer graph ‘pulls’ the projection of the
coarse graph around it as tightly as possible.
We derive the equations for α̈ and β̈ using Lagrangian mechanics. To
simplify the derivation we pretend that both graph layouts are stationary,
and that the displacements δi behave like springs between the fine graph
and the projected coarse graph, acting on α and β via ‘generalized forces.’
By setting up appropriate potential and kinetic energy terms, the Euler-
Lagrange equations yield:
X
α̈ = n1 δ i y Ti + y i δ Ti (6)
i
X
1
β̈ = n δi (7)
i
xi = δ i + β + αy i (8)
| {z }
proj. position
9
Let F i be the forces acting on the vertex xi . Substituting Eqn (10) into ẍi =
F i and rearranging, one obtains an equation of motion for the displacement:
where φ is a time dilation factor to account for the differing time scales of
the coarse and fine graph. Carrying this through to the acceleration equation
yields the equation of motion
If for example the coarser graph layout converged at a rate twice that of the
finer graph, we might take φ = 21 , with the effect that we would discount
the projected acceleration ÿ i by a factor of φ2 = 14 . In practice we have used
values of 0.1 ≤ φ ≤ 0.25. Applied across multiple levels of coarse graphs,
we call this approach multilevel time dilation.
In addition to the spring and repulsion forces in F i , we include a drag
term F di = −dδ̇ i in the forces of Eqn (13).
10
3.3 Multilevel dynamics
To handle multiple levels of coarse graphs, we iterate the two-level dynam-
ics. The dynamics simulation simultaneously integrates the following equa-
tions:
• The equations of motion for the vertices in the coarsest graph, using
the single-level dynamics of Section 3.1.
• The equations for the projection α, β between each coarser and finer
graph pair (Section 3.2.1).
Theorem 3.1. Let (X, Ẋ) be an equilibrium position of the two-level dy-
namics, where X = (δ 1 , δ 2 , . . . , α, β, y 1 , y 2 , . . .), and Ẍ = Ẋ = 0. Then,
(x1 , x2 , . . . , xn ) is an equilibrium position of the single-level dynamics, where
xi = δ i + αy i + β, and the single-level potential gradient ∇V = 0 (Eqn (1))
vanishes there.
Proof. Since Ẋ = 0, the drag terms vanish from all equations of motion.
Substituting Ẋ = 0 and Ẍ = 0 into Eqn (13) yields F i = 0 for each vertex.
Now consider the single-level dynamics (Section 3.1) using the positions xi
obtained from xi = δi + αyi + β (Eqn (5)). From ẍi = F i we have have
ẍi = 0 for each i. The Euler-Lagrange equations for the single level layout
are (Eqn (3)):
d ∂L ∂
− L=0
dt ∂ ẋi ∂xi
11
d ∂L ∂
Since dt ∂ ẋi = ẍi = 0, we have − ∂xi L = 0. Using L = T − V and that the
kinetic energy T does not depend on xi , we obtain
∂
V =0
∂xi
for each i. Therefore ∇V = 0 at this point.
4 Dynamic coarsening
As vertices and edges are added to and removed from the base graph G =
(V, E), our system dynamically maintains the coarser graphs G1 , G2 , . . . , Gm .
Each vertex in a coarse graph may correspond to several vertices in the base
graph, which is to say, each coarse graph defines a partition of the vertices
in the base graph. It is useful to describe coarse vertices as subsets of V .
For convenience we define a finest graph G0 isomorphic to G, with vertices
V0 = {{v} : v ∈ V }, and edges E0 = {({v1 }, {v2 }) : (v1 , v2 ) ∈ E}.
Coarser graphs are obtained by merging vertices via set union. The se-
quence V0 , V1 , . . . , Vm of of coarse graph vertices forms a chain in the lattice
of partitions of V ; we need to maintain this chain of partitions as changes
are made to the base graph V0 .
We have devised an algorithm that efficiently maintains Gi+1 in response
to changes in Gi . By applying this algorithm at each level the entire chain
G1 , G2 , . . . , Gm is maintained.
We present a fully dynamic, Las Vegas-style randomized graph algorithm
for maintaining a coarsened version of a graph. For graphs of bounded de-
gree, this algorithm requires O(1) operations on average per edge insertion
or removal.
Our algorithm is based on the traditional matching approach to coarsen-
ing developed by Hendrickson and Leland [HL95]. Recall that a matching
of a graph G = (V, E) is a subset of edges M ⊆ E satisfying the restriction
that no two edges of M share a common vertex. A matching is maximal if
it is not properly contained in another matching. A maximal matching can
be found by considering edges one at a time and adding them if they do
not conflict with an edge already in M . (The problem of finding a maximal
matching should not be confused with that of finding a maximum cardinality
matching, a more difficult problem.)
12
4.1 Dynamically maintaining the matching
We begin by making the matching unique. We do this by fixing a total order
< on the edges, chosen uniformly at random. (In practice, we compute <
using a bijective hash function.) To produce a matching we can consider
each edge in ascending order by <, adding it to the matching if it does not
conflict with a previously matched edge. If e1 < e2 , we say that e1 has
priority over e2 for matching.
Our basic analysis tool is the edge graph G∗ = (E, S) whose vertices are
the edges of G, and e1 Se2 when the edges share a vertex. A set of edges
M is a matching on G if and only if M is an independent set of vertices in
G∗ . From G∗ we can define an edge dependence graph E = (E, →) which is
a directed version of G∗ :
Since < is a total order, the edge dependence graph E is acyclic. Figure 2
shows an example.
Building a matching by considering the edges in order of < is equivalent
to a simple rule: e is matched if and only if there is no edge e0 ∈ M such that
e0 → e. We can express this rule as a set of match equations whose solution
can be maintained by simple change propagation. Let m : E → {⊥, >}
indicate whether an edge is matched: m(e) = > if and only if e ∈ M . The
match equation for an edge e ∈ E is:
^
m(e) = ¬m(e0 )
e0 : e0 →e
V
where by convention ∅ = >.
To evaluate the match equations we place the edges to be considered for
matching in a priority queue ordered by <, so that highest priority edges
are considered first. The match equations can then be evaluated using a
straightforward change propagation algorithm:
While the priority queue is not empty:
1. Retrieve the highest priority edge e = (v1 , v2 ) from the queue and
evaluate its match equation m(e).
13
e1
e1
e3
e2 e3
e4 e4
e7
e5 e6 e5
e7
eG 1[7
7
77
e 77
E O4U++ aCC 777
+ CCC 77
e +++ CCC 77
@ O5 ++ CC77
++ CC7
C7
e +
7 aC ++ = e3
CC +
CC + {{{{
{
e2 e6
e1
e7
e5 e6
14
Both match(e) and unmatch(e) add the dependent edges of e to the queue,
so that changes ripple through the graph.
Figure 3 summarizes the basic steps required to maintain the coarser
graph (V 0 , E 0 ) as edges and vertices are added and removed to the finer
graph.
15
D YNAMIC -M ATCH operations
We use v to indicate the coarse version of a vertex v.
} z
e4 fc e1 ` e5 v f o e7 e3 f e2 o e6
16
following paths that move from higher to lower priority vertices. We bound
the expected value of N (e) given its priority ρ(e) = η: we can always reach
e from itself, and we can follow any edges to lower priorities:
X
E[N (e) | ρ(e) = η] ≤ 1 + Pr(ρ(e0 ) < η) ·E[N (e0 ) | ρ(e0 ) < η] (14)
0 0
| {z }
e : eSe =η
Isolating the integral and differentiating yields the ODE g(η) = k −1 g 0 (η),
which has the solution g(η) = eηk , using the boundary condition g(0) = 1
obtained from Eqn (20). Since 0 ≤ η ≤ 1, g(η) ≤ ek . Therefore, for every
e ∈ E, the number of reachable vertices satisfies E[N (e)] ≤ ek .
Note that the upper bound of O(ek ) vertices reachable depends only on
the maximum degree, and not on the size of the graph.
We now prove Theorem 4.1.
17
If a max heap is used to implement the priority queue, O(de2d ) operations
are needed to insert and remove these edges. Therefore the randomized
complexity is O(de2d ).
In future work we hope to extend our analysis to show that the entire
sequence of coarse graphs G1 , G2 , . . . , Gm can be efficiently maintained. In
practice, iterating the algorithm described here appears to work very well.
5 Implementation
Our system is implemented in C++, using OpenGL and pthreads. The graph
animator runs in a separate thread from the user threads. The basic API is
simple, with methods newVertex() and newEdge(v1 , v2 ) handling vertex and
edge creation, and destructors handling their removal.
For static graphs, we have so far successfully used up to six levels of
coarsening, with the coarsened graphs computed in advance. With more
than six levels we are encountering numerical stability problems that seem
to be related to the projection dynamics.
For dynamic graphs we have used three levels (the base graph plus two
coarser versions), with the third-level graph being maintained from the ac-
tions of the dynamic coarsener for the first-level graph. At four levels we
encounter a subtle bug in our dynamic coarsening implementation we have
not yet resolved.
5.1 Parallelization
Our single-level dynamics implementation is parallelized. Each frame en-
tails two expensive operations: rendering and force calculations. We use the
Barnes-Hut tree to divide the force calculations evenly among the worker
threads; this results in good locality of reference, since vertices that interact
through edge forces or near-field repulsions are often handled by the same
thread. Rendering is performed in a separate thread, with time step t being
rendered while step t+δt is being computed. The accompanying animations
were rendered on an 8-core (2x4) iMac using OpenGL, compiled with g++
at -O3.
Our multilevel dynamics engine is not yet parallelized, so the accompa-
nying demonstrations of this are rendered on a single core. Parallelizing the
multilevel dynamics engine remains for future work.
18
6 Applications
We include with this paper two demonstrations of applications:
In addition, we mention that the graph visualizer was of great use in de-
bugging itself, particularly in tracking down errors in the dynamic matching
implementation.
7 Conclusions
We have described a novel approach to real-time visualization of dynamic
graphs. Our approach combines the benefits of multilevel force-directed
graph layout with the ability to render rapidly changing graphs in real
time. We have also contributed a novel and efficient method for dynami-
cally maintaining coarser versions of a graph.
References
[BH86] B ARNES J. E., H UT P.: A hierarchical O(N log N ) force-
calculation algorithm. Nature 324, 6270 (1986), 446–449.
[EGK∗ 04] E LLSON J., G ANSNER E. R., KOUTSOFIOS E., N ORTH S. C.,
W OODHULL G.: Graphviz and dynagraph – static and dynamic
19
graph drawing tools. In Graph Drawing Software, Jünger M.,
Mutzel P., (Eds.), Mathematics and Visualization. Springer, 2004,
pp. 127–148.
[FLM94] F RICK A., L UDWIG A., M EHLDAU H.: A fast adaptive layout algo-
rithm for undirected graphs. In Graph Drawing (1994), Tamassia
R., Tollis I. G., (Eds.), vol. 894 of Lecture Notes in Computer Sci-
ence, Springer, pp. 388–403.
[FT07a] F RISHMAN Y., TAL A.: Multi-level graph layout on the GPU. IEEE
Trans. Vis. Comput. Graph 13, 6 (2007), 1310–1319.
[FT07b] F RISHMAN Y., TAL A.: Online dynamic graph drawing. In EuroVis
(2007), Museth K., Möller T., Ynnerman A., (Eds.), Eurographics
Association, pp. 75–82.
[HEW98] H UANG M. L., E ADES P., WANG J.: On-line animated visualiza-
tion of huge graphs using a modified spring algorithm. J. Visual
Languages and Computing 9, 6 (Dec. 1998), 623–645.
[HJ04] H ACHUL S., J ÜNGER M.: Drawing large graphs with a potential-
field-based multilevel algorithm. In Graph Drawing (2004), Pach
J., (Ed.), vol. 3383 of Lecture Notes in Computer Science, Springer,
pp. 285–295.
[HK02] H AREL D., KOREN Y.: A fast multi-scale method for drawing large
graphs. J. Graph Algorithms Appl 6, 3 (2002), 179–202.
20
[HMM00] H ERMAN , M ELANÇON G., M ARSHALL M. S.: Graph visualiza-
tion and navigation in information visualization: A survey. IEEE
Transactions on Visualization and Computer Graphics 6, 1 (Jan./
Mar. 2000), 24–43.
[KCH02] KOREN Y., C ARMEL L., H AREL D.: ACE: A fast multiscale eigen-
vectors computation for drawing huge graphs. In INFOVIS ’02:
Proceedings of the IEEE Symposium on Information Visualization
(InfoVis’02) (Washington, DC, USA, 2002), IEEE Computer Soci-
ety, p. 137.
[KK89] KAMADA T., KAWAI S.: An algorithm for drawing general undi-
rected graphs. Inf. Process. Lett. 31, 1 (1989), 7–15.
[STT81] S UGIYAMA K., TAGAWA S., T ODA M.: Methods for visual under-
standing of hierarchical systems. IEEE Transactions on Systems,
Man, and Cybernetics 11, 4 (1981), 109–125.
21