You are on page 1of 35

A R eview  of Force G raphing A lgorithm s

Jam es C hurch


June 22, 2010
Outline
● Goal of Force Graphing Algorithms
● Review of Hooke’s Law
● Three Main Algorithms
– Spring Model
– Simulated Annealing
– The Sugiyama Algorithm
● 8 Variations
● Review
Problem Statement
● G = (V, E)
● Assume undirected and unweighted
● How do we display this graph?
● There are numerous graph drawing algorithms.
● Force-based algorithms draw inspiration from
physics.
Hooke’s Law
● Approximate the behavior of springs
● Springs, whether compressed or extended,
when released will return to the natural length
● Force on a spring equals: -k * x, where
– k is the force constant, x is the displacement
distance from natural length
Goals
● Aesthetics
– Minimize edge crossings
– Verities evenly distributed
– Minimize drawing area
– Maximize symmetries
– Maximize angular resolution
Goals
3 Algorithms.
Sugiyama Algorithm
● Sugiyama, Tagawa, and Toda (1981)
● The graph is assumed to be in layers.
● Edges can only connect nodes in different
layers.
Sugiyama Algorithm
● The algorithm is in four stages:
– Stage 1: Refit the graph into layers (if not done so
already)
– Stage 2: Reshape the vertices at each level to
reduce edge crossings
– Stage 3: Reshape the vertices at each level to
reduce edge lengths
– Stage 4: Display the graph
Sugiyama Algorithm
● If an edge stretches across multiple layers,
placeholder nodes are added to in between
layers.
● Barycenter for a node: the minimum distance
from a level to every other node.
● Computing the barycenter of each node
automatically reduces edge crossings.
● Nodes are moved based on their barycenters.
● Nodes with smaller barycenters are given a
higher priority.
Spring Model
● Peter Eades, 1984
● Vertices are replaced with rings.
● Edges are replaced with springs.
● Each spring applies a force on the rings,
moving the rings slightly.
● After several iterations of slight movements, the
springs reach an equilibrium point
Spring Model
● Vertices that are connected by an edge attract.
– C1 * log(D * C2)
– D: length of the spring
– C1, C2: Constants
● Vertices that are not connected repel.
– C3 / sqrt(D)
– C3: Constant
● All forced are multiplied by C4 and repeated
100 times.
Simulated Annealing
● Davidson and Harel (1989)
● Each node uses an cost function, which consist
of:
– Potential Energy for each node: aij = C1 / (dij)2
– Borderline Energy C2 ( 1/r2 + 1/l2 + 1/t2 1/b2)
– Energy of each edge: C3 * (dk)2
– Distance from node to an edge: C4 / (gkl)2
● d_ij: distance between two nodes.
● C1, C2, C3, C4 are constants.

● r, l, t, b: distance from right, left, top, bottom

● g_kl: distance from node k to edge l


Simulated Annealing
● In addition to the cost function, there is a
penalty for each edge crossings: C5 (a
constant)
● The cost function is multiplied by a temperature
– High temperature = greater movement
– Low temperature = lesser movement
Simulated Annealing
● Cooling Function. Over time, the temperature of
the area "cools".
– Initial temperature is arbitrarily high # in degrees
– Trials per degree: 30 * # of nodes
– Cooling function = Tp+1 = C6 * Tp
● Termination condition: little or no movement for
three iterations.

Algorithm runs in O(V2 * E)
8 Variations.
Kamada and Kawai (1989)
● Variation of Eades’ spring model approach.
● Each edge has a starting length of lij
● Each edge desires to have a length equal to L
– L: Usually a function of the size of the
graphing area.
Kamada and Kawai (1989)
● dij: the shortest path of edge lengths between
nodes i and j.
● kij: strength of the spring equal to K / dij
● K: Constant
Fruchterman & Reingold (1990)
● Includes ideas of Eades and Kamada using a
Spring Force graph
● Includes ideas of Davidson and Harel using
Simulated Annealing
● Cost function is based on Hooke's Law
● Optimal distance between vertices: C *
sqrt(area / number of verticies)
● Proposes an idea for a “grid-variant” partitioning
scheme.
Tunkelang (1994)
● Step 1: Compute a minimal height spanning
tree of the graph.
● The graph nodes are placed so that the root
node is in the center and subsequent nodes
surround it in rings.
● Edges strive for a target edge length that is a
parameter set by the user.
– Larger length: better graph.
– Smaller length: faster graph.
Tunkelang (1994)
● Attraction forces are edges; repulsion forces
are other nodes.
● Attraction force: wa * d2
2
● Repulsion force: wr / d
● d: distance between two nodes
● wa: weight given to attractive force.
● wr: weight given to repulsive force.
Tunkelang (1994)
● Target edge length is suggested to be:
● (wr/wa)1/4
● Using the uniform grid approach to counting
edge crossings, nodes are pushed until a
minimal arrangement is reached.
Frick, Ludwig, Mehldau (1995)
● Builds on the work of Davidson and Harel
(1989).
● Instead of having a global temperature for
simulated annealing, each node has a local
temperature.
● Each node starts with the same temperature.
● After each node moves, the temperature
decreases based on the movement. If the node
appears to be oscillating, the temperature
decreases quickly. If not, the temperature
decreases slowly.
Gansner and North (1998)
● Purpose of this algorithm is to improve the
results of the Kamada and Kawai algorithm.
● Phase 1: Perform the original Kamada and
Kawai algorithm.
● Phase 2: Magnify the placement of all vertices,
giving them sufficient space.
● For each vertex, compute a Voronoi diagram.
● Move the vertex to the nearest center. Vertices
gradually move away from each other in an
orderly fashion.
Bertault (1999)
● Initial placement of nodes is made by the
graph's owner.
● Edge Crossings should be preserved, not
minimized.
● Cost functions is split between attractive forces
(edges), repulsive forces (nodes), and repulsing
forces (nodes versus edges).
Bertault (1999)
● For each node, 8 "node
arcs" are computed.
These are arcs equal to
1/8th of a circle of
equal proportions. For
each arch, a calculation
is made regarding the
maximum movement
that can be made
without changing node
crossings.
Walshaw (2000)
● Implements Frucherman and Reingold's grid-
variant algorithm.
● Cost function between a vertex and another
vertex (global cost): -Cwk2/x
– C: Constant
– k: natural length of the spring
– w: Number of vertices
– x: current length of the spring
Walshaw (2000)
● Vertices in the same grid region are considered
local and use a different cost function: ((x - k) /
d) - global cost
– d: distance between the two vertices.
– k (natural edge length) is set to the average edge
length
● The cooling function at each iteration is 0.95
times the previous temperature.
Walshaw (2000)
● If x (current length of spring) is sufficiently
large, the authors say that the spring is
stretched so far that it has no impact. This is
used as excuse to speed up the algorithm by a
small factor.
Gajer, Goodrich, and Kobourov
(2004)
● Differs from most algorithms in that they use an
algorithm for initial placement.
● Similar to Tunkelang in that distinction is made
between local and global points.
● Local is determined by a limited breadth-first
search algorithm.
● Cost function is based on the Kamada and
Kawai cost function (1989)
Gajer, Goodrich, and Kobourov
(2004)
● Initial placement begins by
looking for three edges in a
triangle formation.
● These vertices are refined to
fit along the edge of a circle.
● This process of finding 3
edges in a triangle shape is
repeated until the remaining
edges can be place along
the circle.
Review
Sugiyama, Tagawa,
& Toda (1981)

Davidson &
Eades (1984)
Harel (1989)

Kamada & Fruchterman &


Kawai (1989) Reingold (1990)

Gansner & Frick, Ludwig, &


Tunkelang (1994)
North (1998) Mehldau (1995)

Gajer, Goodrich, &


Walshaw (2000) Bertault (1999)
Kobourov (2004)
References
● F. Bertault. A force-directed algorithm that preserves edge crossing properties. In
Graph Drawing, pages 351–358. Springer, 1999.
● R. Davidson and D. Harel. Drawing graphs nicely using simulated annealing. ACM
Transactions on Graphics (TOG), 15(4):301–331, 1996.
● Eades. A heuristic for graph drawing. Congressus numerantium, 42(149160):194–
202, 1984.
● A. Frick, A. Ludwig, and H. Mehldau. A fast adaptive layout algorithm for undirected
graphs. Graph Drawing (Proc. GD &# 039; 94), volume 894 of Lecture Notes in
Computer Science, 1995.
● T.M.J. Fruchterman and E.M. Reingold. Graph drawing by force-directed placement.
Software- Practice and Experience, 21(11):1129–1164, 1991.
● P. Gajer, M. Goodrich, and S. Kobourov. A multi-dimensional approach to force-
directed layouts of large graphs. In Graph Drawing, pages 211–221. Springer.
References
● E. Gansner and S. North. Improved force-directed layouts. In Graph Drawing, pages
364–373. Springer, 1998.
● T. Kamada and S. Kawai. An algorithm for drawing general undirected graphs.
Information processing letters, 31(1):7–15, 1989.
● K. Sugiyama and K. Misue. Graph drawing by the magnetic spring model. Journal of
Visual Languages and Computing, 6(3):217–231, 1995.
● D. Tunkelang. A practical approach to drawing undirected graphs. Carnegie Mellon
University, 1994.
● C. Walshaw. A multilevel algorithm for force-directed graph drawing. In Graph
Drawing, pages 31–55. Springer, 2000.
Additional References
● F. Brandenburg, M. Himsolt, and C. Rohrer. An experimental comparison of force-directed and
randomized graph drawing algorithms. In Graph Drawing, pages 76–87. Springer.
● G. Di Battista, P. Eades, R. Tamassia, and I.G. Tollis. Algorithms for drawing graphs: an
annotated bibliography. Computational Geometry-Theory and Application, 4(5):235–282, 1994.
● G. Di Battista, A. Garg, G. Liotta, R. Tamassia, E. Tassinari, and F. Vargiu. An experimental
comparison of four graph drawing algorithms* 1. Computational Geometry, 7(5-6):303–325,
1997.
● S. Sim. Automatic graph drawing algorithms. Manuscript, available att, 1996.

You might also like