Graph Drawing
past - present - future
Prof. Dr. Franz J. Brandenburg University of Passau
Oct. 2002
Summary
• past = standard algorithms = before 1990
– fundamental algorithms
• Reingold-Tilford for trees
• Sugiyama for DAGs (acyclic)
• spring embedders for general graphs
• Tutte embeddings for planar graphs
• present = advances = 1990 - 2000
– improved versions – upwards planarity
• future = todo = 2001 - 2015
– new and actual directions
– open problems
Literature
G. DiBattista, P. Eades, R. Tamassia, I.G. Tollis
Draph Drawing, Prentice Hall, 1999 M. Kaufmann, D. Wagner (eds).
Drawing Graphs: Methods and Models LNCS 2025, Springer Verlag, 2001
Proceedings Graph Drawing Symposia, 1994 - 2001
LNCS 894, 1027, 1190, 1353, 1547, 1731,1984, 2265
Journals
JGAA, Comput. Geometry, Int.J. Comput Geom Appl, TCS,...
G. DiBattista, P. Eades, R. Tamassia, I.G. Tollis
Algorithms for Drawing Graphs. an annotated bibliography
Comp. Geom. Theory Appl. 4, 1994
"A Survey of Graph Layout Problems“
ACM Computing Surveys, Vol 34, 2002, 313-356
History
• Aristoteles (-384 - -322)
noli turbare circulos meos
• L. Euler (1707-1783)
Königsberg bridge problem planar graphs
• E. Steinitz (1871 - 1928)
planar graphs (polyhedrons, drawn by hand)
• H.W. Tutte (1963)
convex drawings of planar graphs
• D. E. Knuth (1970)
"How shall we draw a tree“
Special Reference:
What is Graph Drawing
• mapping d : G ---> d(G) into R
2(or R
3)
a transformation from topology to geometry
assign coordinates to the nodes and the bends of edges
– placement of nodes v ---> (X(v), Y(v)) – routing of edges e ---> polyline
• graph embedding into the grids
– map nodes into grid points
– route edges as paths along grid lines
• cost measures for quality
– area, edge length, crossings, bends, congestion, dilation,...
• topology ---> shape ---> (geo)metric approach
– identify graphs up to topology / shape / geometry
isomorphism, including faces, translation & rotation
Classifications for Drawings
• trees
• ordered trees hierarchical radial
• embeddings on the grid (H-, upwards, hv)
• other techniques (organigrams, inclusion diagrams)
• acyclic graphs, DAGs
• Sugiyama algorithm
• general graphs
• force directed approaches
• multi-dimensional approach
• planar graphs
• straight line (FPP)
• orthogonal (Tamassia‘s flow technique)
• visibility
Ordered Trees
• D.E. Knuth (1970)
– How shall we draw a tree ? Top-down!
Knuth’s algorithm
printed by texteditor symbols / \ – compute spaces on each layer
left-aligned / \
\ \ / \ \
\ _\ \
/ / \ / \
Reingold-Tilford Algorithm (1)
• Aesthetics
– horizontal by layer => Y-coordinate determined – left-right ordering
– father centralized over its sons – planar
– isomorphic subtrees are displayed isomorphic – minimal horizontal distance
– integer coordinates (grid)
• Implementation
– bottom-up in postorder
– compute the right-contour of T
leftand the left-contour of T
right– compute minimal shifts for T
leftand T
right– place the father above T
leftand T
right• O(n)
Reingold-Tilford Algorithm (2)
• O(n) by
– cost(T) = cost(T
1) + cost(T
2) + min{height(T
1), height(T
2)}
= size(T) – height(T)
• quality
– symmetry and isomorphism: for free – in practice: OK
– in theory: bad: O(n
2) area and too wide by (l l r)*
• NP-hard for minimal width/area
– grid + symmetry + center (Supowit-Reingold, Acta Inf. 1983)
no -approximation (1/24)
– grid + ternary + center (Edler, Passau 98)
Reingold-Tilford Algorithm (3)
• advanced features = many parameters
– arbitrary degree (Walker’s algorithm) – arbitrary nodes sizes (width, height)
– leveling: global or local for each subtree (distances) – father: center, median (innermost, outermost children) – grid (integrality)
– edge anchors
– routing: straight-line, orthogonal, bus-layout
my conclusion: ordered tree drawing is solved!
Radial Tree Drawings
• applications
– block-tree of 2-connected components – (minimal) spanning trees
– telekommunication structures
• radial algorithm by P. Eades
– place nodes on concentric circles by level
– partition the circle into sectors of width „number of leaves“
– draw the subtrees into their sectors – the order is preserved
– planarity is not guaranteed
• Graphlet
– global and local leveling
• H-trees (D4 = NESW)
• T-layout (D3 = ESW)
• hv-layout (D2 = ES)
Grid Embeddings of Free Trees
free = no left-right order
orthogonal drawings place the nodes on grid points
route edges along grid lines / paths
how many directions ?
13
Complete Binary Trees
• H-tree layout
– area (n), since side-length(4n) = 2•side-length(2n) – edge length ( ) with hyper-H-layout
• T-layout (upwards)
– „nothing new“
• hv-layout
– area (n) for complete (balanced) trees
– area (n logn) for arbitrary trees with width ≤ logn by h- and v- compositions
n logn
horizontal composition
vertical composition
Hierarchical Drawings, Sugiyama
• directed acyclic graphs, DAGs
K. Sugiyama, S. Tagawa, and M. Toda IEEE Trans SCM 1981
(1) break cycles
(2) compute layering, the Y-coordinates
and insert dummy nodes for long-span edges (3) crossing reduction
repeat
down phase: sort next layer
placement on lower layer up phase: sort previous layer
placement on upper layer
until DONE
15
Force Directed Methods
idea: a spring model
select optimal edge length (node distance) k repeat
for each node v do
for each pair of nodes (u, v)
compute repulsive force f
r(u,v) = - c•
for each edge e = (u,v)
compute attractive force f
a(u,v) = c•
sum all force vectors F(v) = ∑ f
r(u,v) + ∑ f
a(u,v) move node v according to F(v)
until DONE
d(u,v) 2 k
€
k 2
d(u,v)
Tutte’s Barycenter Algorithm
G is planar and tri-connected (mesh of a convex polytope) drawing(G) is planar, straight-line, convex
in O(n logn) Algorithm:
select an outer face F = (v
1,...,v
k) draw F convex e.g. as a k-gon
fix the X- and Y- coordinates of F by d(v
i) = (x
i, y
i), 1≤i≤k place each node v at the barycenter of its neighbours
compute nn matrix A
A[u,v] = 1/deg(v) for each edge e=(u, v) A[v,v] = -1
and A[v
i, v
i] = x
i(resp. y
i) and solve Ax = 0 (Ay = 0) Correctness and Complexity:
Drawing Styles
• polyline drawings
reduce bends, no sharp angles, polish by with Bezier splines
• straight-line
uniform (short) edge length
• orthogonal drawings
minimize bends
• planar drawings
minimize crossings and bends
• grid embeddings
grid coordinates for nodes and bend-points
• visibility
horizontal bar nodes and vertical visibility
Aesthetics (1)
• What is a nice drawing ?
• What makes drawings understandable or readable?
• How can we measure quality?
• Can we formalize aesthetics ?
• Chinese proverb
”A picture is worth a thousand words“
• R. Feynman (Nobel prize in Physics)
”It’s all visual“
• R.A. Earnshaw (a poineer in computer graphics, 1973)
”visualization uses interactive compute graphics to help provide insight on complicated problems, models or systems“.
”Scientific visualization is exploring data and information
graphically, gaining understanding and insights into the data“
Aesthetics (2)
• recognize complex situations faster
learn things more easily (sketch of a proof)
– H. Purchase with students experiments on graph drawings (GD97)
• chess players recognize patterns
• recognize graph properties
– a path between two nodes – connectivity
– Hamilton cycle (on the outer face)
– interactive graph drawing competition (GD2003 )
Aesthetics (3)
D.E. Knuth (GD' 1996)
• ”Graph drawing is the best possible field I can think of:
It merges aesthetics, mathematical beauty and wonderful algorithms.
It therefore provides a harmonic balance between the left and right brain parts.“
• “A good graph drawing algorithm should leave something for the user‘s satisfaction.”
No perfect algorithm!
R. Tamassia (IEEE SMC 1988, p.62)
• aesthetics are criteria for graphical aspects of readability
Aesthetic Criteria
• visual complexity
how long does it take to ”see everything“, to get the overview
• regularity
repetitions, fractals
• symmetry
geometric symmetry by rotation, reflection, translation
• consistence
coincidence of the picture and the intended meaning
• form, size and proportionality
• common drawing styles
e.g. biochemical pathways, organigrams, ER-diagrams,
• algorithmic efficiency
seconds, not hours/years
Aesthetics Formalized
• resolution or geometric criteria
– area (2), volume (3D), height, width, aspect ratio
– edge length (sum, max, all uniform (Hartfield&Ringel, Pearls..) ) – angular resolution (avoid small angles)
– uniform node distribution
– integrality, grid drawings/embeddings
• all nodes
• all nodes and bends of polylines
• all nodes and edges (grid embedding)
• sizes of all faces (Hartfield&Ringel, Pearls in Graph Theory)
Aesthetics Formalized
• discrete criteria
– crossings – bends
– load factor (overlaps of nodes) – congestion (parallel edges)
– edit complexity (insertions, deletions, moves)
• symmetry
– center father above the children
– geometric symmetry (rotation, reflection) – graph symmetry, graph isomorphy
• constraints
– Sesame street relations (left-right, top-down)
– place distinguished nodes (e.g. center, at the border)
– clustering
Formalization
an information theoretic approach to aesthetics
Max Bense, designer at Bauhouse school (1930)
order redundancy complexity information
order = regularity
complexity = descriptional complexity, bit representation redundancy = log n – H(∑)
information = information content
”nice“ if well-ordered, symmetric
”nice“ if high redundancy, not overloaded, not compressed
=
aesthetics =
Aesthetics = Optimization
• MIN {cost(d(G)) | d(G) is feasible}
cost measures the aesthetic criteria feasible guarantees no overlaps etc
• most important
fulfill the common standards
(hierarchical, planar, left-right; bio-informatics)
• be ”almost“ optimal
do not waste space,
but do not minimize the area
• "aesthetics cannot be formalized“
there is a gap between the user's view and the formalism
D.E. Knuth (Graph Drawing '96)
References Aesthetics
G. Nees,
Formel, Farbe, Form Computerästhetik für Medien und Design. Springer (1995) H.W. Franke
Computergraphik - Computerkunst (1971) R. Tamassia, G. Di Battista, C, Batini
"Automatic graph drawing and readability of diagrams“, IEEE SMC 18 (1988), 61-79 C. Batini, E. Nardelli, R. Tamassia
"A layout algorithm for data flow diagrams“, IEEE-SE 12 (1986), 538-546 C. Kosak, J. Marks, S. Shieber,
"Automating the layout of network diagrams with specific visual organization", IEEE-SMC 24 (1994), 440-454
H.C. Purchase, R. Cohen, and M. James
"Validating graph drawing aesthetics“, Proc. GD'95, LNCS 1027 (1996), 435-446 C. Ding, P. Mateti
"A framework for the automated drawing of data structure diagrams"
IEEE SE-16 (1990), 543-557 J. Manning
"Computational complexity of geometric symmetry detection in graphs“.LNCS 597 (1991), 1-
7
present
1990-2000
theoretical foundations, extensions, improvements
Graph Drawing Symposia ’93 – ’02
Trees
• ordered trees solved
Reingold-Tilford algorithm with extensions radial drawings
• free trees something TODO preserve planarity
swap left-right subtrees to minimize the area --> NP ?
– complete trees solved H-trees in O(n) area
hv-trees in O(n) area
Exact Bounds are NP-hard
• H-tree
Bhatt-Cosmadakis reduction of NotAllEqual3SAT
area(T) ≤ w•h iff width(T) ≤ w iff NEA3SAT edge-length = 1 iff NEA3SAT
x 1 x 2 x 3 x 4
c 3
c 3
c 2
c 1
c 1
c 2
"upper hole" iff x occurs in c
i j
Area of binary Trees on the Grid
polyline orthogonal
polyline, bends
straight-line
grid or Fary
straight-ortho
rectangular
4 directions H-tree
(n) (n)
Leiserson 80, Valiant 81, Garg etal IJCGA97
O( n loglogn ) O( n loglogn )
Chan etal GD96 Shin etal, CG2000
3 directions upwards or T-layout
(n)
Garg etal IJCGA96
( n loglogn )
Garg etalIJCGA96,
O( n loglogn )
Garg et aI JCGA96, Shin et al CG 2000
Chan et al, CG02
2 directions hv-layout
(n logn) (n logn) (n logn) (n logn)
(n logn)
O (n logn)
the lower bound with Given Width
choose an arbitrary width, e.g. W = √n or W = log n consider the following tree T
T = a chain of length n/2W and a complete binary tree of site W/2 at each W‘s node of the chain.
These nodes are called T-joins.
CLAIM 1
Each complete tree of size k needs k in each dimension (height, width)
CLAIM 2
Each rectangle of width W-1 and height (logW)/2 has at most one T-join
THEN
area(T) ≥ W * (n/W)*logW) = n*log W which is Ω(n logn) for W = na
W-1 nodes T-join
complete tree of size W/2
log n/2W
n/2 nodes in n/2W lines
complete tree of size W/2
complete tree of size W/2
„waiste height“
But
complete tree of size W/2
log n/2W
n/2 nodes in n/2W lines
complete tree of size W/2
complete tree of size W/2
W * logW, e.g. logn * lolgogn
1 unit
area:
2W
Tree Folding
1
2 11--10--9--8--7
12
3 19--18--17--16 15--14--13
24--23 22--21--20
4 31--30--29 28--27--26 25
32
40 39--38 37--36 35--34 33
5 47--46 45--44 43--42 41
49 48
57 56 55 54 53 52 51 50
O(n) area
for complete tree
Techniques
• make trees left-heavy
|T
left| ≥ |T
right|
a weaker version of balance with right-depth(T) ≤ logn
• recursive winding
partition in subtrees of appropriate sizes and merge
• solve complex recursion formulas
References:
T. Chan, M. Goodrich, S.R. Kosaraju, R. Tamassia, Comput. Geom. 23 (2002)
A. Garg, M. Goodrich, R. Tamassia, Int. J. Comput. Geom. Appl. 6 (1996)
C. Shin, S.K. Kim K-Y. Chwa, Comput Geom. 15 (2000)
other Tree Drawing Conventions
• standard
Knuth ”how shall we draw a tree“
Reingold-Tilford algorithm
• MS-file system
special hv-drawings
• tip-over = horizontal+vertical tip overs
• inclusion diagrams
– minimal size = NP-hard
by PARTITION
OPEN Problems on Trees
• H-tree layouts
– area of straight-line and straight-orthogonal drawings, O(n loglogn) – sum of edge lengths O(n logloglog n)
(Shin et al. IPL1998)– bends
• T-tree layouts (upwards)
– area of straight-orthogonal drawings (in Chan et al CG23 (2002))
my CLAIM: O(n loglogn
2) area by twisted windings Correction 9.10.02
• hv-layouts
– which trees (weak balance) have area O(n) ?
• better aspect ratio (width / height = 1)
– often: n/ logn
– Wanted: arbitrary
Advanced Sugiyama
• synonyms:
hierarchical = DAG-layouts = Sugiyma style
• aesthetics and conventions
– edges point downwards
– long edges should be avoided, i.e. few dummy nodes – few edge crossings
– many straight (vertical) edges
• the algorithm
– (1) compute layering – (2) crossing reductions – (3) routing with few bends
• extensions
Phase 1: Remove Cycles
¬
feedback arc set problem is NP-hard (Karp 72)
minimize the number of „to be deleted“ edges E
dminimize the number of „to be reversed“ edges E
rmaximal acyclic subgraph by E
a= E – E
dLemma
reverse each „deleted“ edge E
r= E
dheuristics (see Bastert,Matuszewski in LNCS 2025)
• depth-first search (or bfs) and reverse each „backedge“
• problem specific (while-loops, return-jumps, known cycles (acid cycle))
• in-out degree dominance deleting at most m/2 – n/6 edges (Eades et al. 1993)
reverse topsort from the sinks topsort from the sources
sort nodes v by outdegree(v) – indegree(v) keep the outgoing edges (v,w)
and delete the incoming edges (u, v)
Phase 2: Layering
layer span (v) = interval of layers on which v can be placed dummy nodes = nodes on intermediate layers
• topological sorting
ASAP ALAP
computes minimal height layering in O(n+m), min height is solved!
• Coffman-Graham method (multi-processor scheduling)
sort the nodes by their maximal distance from the sources bottom-up assign at most k nodes to each layer
by choosing the largest node whose descendants have already been placed
=> computes layering of width ≤W and height ≤ (2–2/W)•height
min• ILP algorithm of Ganser etal. (1993)
minimize #dummy nodes min{Y(u) – Y(v)-1) | e=(u,v) } is polynomially solvable
gives the ”best“ practical performance
Phase 3: Crossing Minimization
algorithm:
layer by layer sweep
iterative improvement (finitely many rounds) theory:
two-layer crossing minimization is NP-hard
ILP-formulation and branch and cut works well up to 60 nodes method:
repeat in down and up phases
sort next layer by barycenter or median works well and efficient in practice
Who needs something better ?
OPEN
41
Phase 4: Coordinate Assignment
all dummy nodes of a path p should lie on a straight line the deviation is minimized
dev(p) = ∑ (x(v
i) – (v x
i))
2with (v
i)
= i −1
k −1 (x(v k ) −x(v 1 )) +x(v 1 ) x
at most two bends for each long span edge and strict vertical between the bends
integrate into the crossing minimization using heavy weights for dummy vertices and using exstra space
(Sander, TCS2000, Gansner etal)
Extensions
• real nodes with width and height
– recompute the layering from the heights and vertical distances PROBLEM: O(n
2) layers, therefore a coarser grid
PROBLEM: edges cross nodes (maybe unavoidable)
• clusters
– nodes (including paths of dummy nodes) are grouped use weights for the sizes of the clusters
CHALLENGE PROBLEMs:
(1) global crossing minimization over many layers
model and solve (other than as a huge LP) e.g. by clustering
General Graphs
• force directed methods
– in a loop
compute attractive and repulsive forces
and move the nodes according to the force-vectors
• good:
– intuitive concept
– easily adaptable and extensible (more forces)
• bad:
– running time – termination – which forces
– too many parameters: the best selection and default values
– a „bag“ of tricks
Forces
• attractive forces
– along each edge
– proportional to shortest paths
• repulsive forces
– between each pair of nodes (O(n
2) pairs, costly!) – only between closely related nodes (hash grid)
• other forces
– center of gravity (attractive)
– underlying magnetic fields (concentric, radial, horizontal)
– angular forces (between adjacent edges at nodes v)
45
Strength of Forces
• k = an ideal distance between nodes the ideal edge length k , k = 0.75•
€
area n