Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms 1 Tamara Mchedlidze Algorithms for Graph Visualization Force-Directed Algorithms 21.12.2016 INSTITUT F ¨ UR THEORETISCHE INFORMATIK · FAKULT ¨ AT F ¨ UR INFORMATIK Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms
74
Embed
Force-Directed Algorithms Algorithms for Graph Visualization€¦ · Dr. Tamara Mchedlidze Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms 1 Tamara Mchedlidze
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms1
Tamara Mchedlidze
Algorithms for Graph VisualizationForce-Directed Algorithms
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms2
Introduction
Before: always based on some properties: tree,series-parallel graph, planar graph
and on some additional information: ordering of thevertices, decompositions into SP-components
Today: more direct and intuitive method based on physicalanalogies
The methods are very popular: intuitiveness, easy toprogram, generality, fairly satisfactory results,...
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms3
General Layout Problem
Given: Graph G = (V,E)
Find: Clear and readable drawing of G
Which aesthetic criteria wouldyou optimize??
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms3
General Layout Problem
Given: Graph G = (V,E)
Find: Clear and readable drawing of G
Criteria:adjacent nodes are closenon-adjacent far apartedges short, straight-line, similar lengthdensly connected parts (clusters) form communitiesas few crossings as possiblenodes distributed evenly
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms3
General Layout Problem
Given: Graph G = (V,E)
Find: Clear and readable drawing of G
Criteria:adjacent nodes are closenon-adjacent far apartedges short, straight-line, similar lengthdensly connected parts (clusters) form communitiesas few crossings as possiblenodes distributed evenly
! Optimization criteria partially contradict each other
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms4
Example: Fixed edge-length
Given: Graph G = (V,E), required edge length `(e), ∀e ∈ EFind: Drawing of G which realizes all the edge lengths
NP-hard for
edge lengths {1, 2} [Saxe, ’80]
planar drawing with unit edge length [Eades, Wormald, ’90]
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms5
Physical Model
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms5
Physical Model
“To embed a graph we replace the vertices by steel rings and replaceeach edge with a spring to form a mechanical system . . .
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms5
Physical Model
“To embed a graph we replace the vertices by steel rings and replaceeach edge with a spring to form a mechanical system . . . The vertices areplaced in some initial layout and let go so that the spring forces on therings move the system to a minimal energy state.” [Eades, ’84]
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms5
Physical Model
“To embed a graph we replace the vertices by steel rings and replaceeach edge with a spring to form a mechanical system . . . The vertices areplaced in some initial layout and let go so that the spring forces on therings move the system to a minimal energy state.” [Eades, ’84]
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms5
Physical Model
“To embed a graph we replace the vertices by steel rings and replaceeach edge with a spring to form a mechanical system . . . The vertices areplaced in some initial layout and let go so that the spring forces on therings move the system to a minimal energy state.” [Eades, ’84]
So-called spring-embedder algorithms that workaccording to this or similar principles are among themost frequently used graph-drawing methods inpractice.
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms6
Notation
` = `(e) ideal spring length for edge e
pv = (xv, yv) position of node v
||pu − pv|| Euclidean distance between u and v−−→pupv unit vector pointing from u to v
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms7
Spring-Embedder (Eades, 1984)
Model:repulsive force between two non-adjacent nodes u and v
frep(pu, pv) =crep
||pv − pu||2· −−→pupv
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms7
Spring-Embedder (Eades, 1984)
Model:repulsive force between two non-adjacent nodes u and v
frep(pu, pv) =crep
||pv − pu||2· −−→pupv
attractive force between adjacent vertices u and v
fspring(pu, pv) = cspring · log||pu − pv||
`· −−→pvpu
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms7
Spring-Embedder (Eades, 1984)
Model:repulsive force between two non-adjacent nodes u and v
frep(pu, pv) =crep
||pv − pu||2· −−→pupv
attractive force between adjacent vertices u and v
fspring(pu, pv) = cspring · log||pu − pv||
`· −−→pvpu
resulting displacement vector for node v
Fv =∑
u:{u,v}6∈E
frep(pu, pv) +∑
u:{u,v}∈E
fspring(pu, pv)
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms8
local temperaturecos(αv(t)) ≈ 1:similar direction→ increase the temperature
cos(αv(t)) ≈ −1:oscillation→ reduce the temperature
cos(αv(t)) ≈ 0:Rotation→ update rotation counter anddecrease temperature ifnecessary
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms16
Discussion
Advantagesstill very simple algorithmfurther modifications improve layout quality and lead tofaster convergence
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms16
Discussion
Advantagesstill very simple algorithmfurther modifications improve layout quality and lead tofaster convergence
Disadvantagesstability is not guaranteedlocal minima possiblequadratic time for repulsive forces
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms16
Discussion
Advantagesstill very simple algorithmfurther modifications improve layout quality and lead tofaster convergence
Disadvantagesstability is not guaranteedlocal minima possiblequadratic time for repulsive forces
InfluenceVariants of Fruchterman and Reingold algorithms areprobably the most popular force-based methods (originalpaper cited 3500 times (1000 in the past two years))
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms16
Discussion
Advantagesstill very simple algorithmfurther modifications improve layout quality and lead tofaster convergence
Disadvantagesstability is not guaranteedlocal minima possiblequadratic time for repulsive forces
InfluenceVariants of Fruchterman and Reingold algorithms areprobably the most popular force-based methods (originalpaper cited 3500 times (1000 in the past two years))
Could we reduce this?
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms17
Grid Version (Fruchterman, Reingold, 1990)
v
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms17
Grid Version (Fruchterman, Reingold, 1990)
v
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms17
Grid Version (Fruchterman, Reingold, 1990)
v
subdivide plane by a gird
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms17
Grid Version (Fruchterman, Reingold, 1990)
v
subdivide plane by a gird
compute repulsive forcesonly for the nodes in theneighbouring cells
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms17
Grid Version (Fruchterman, Reingold, 1990)
v
subdivide plane by a gird
compute repulsive forcesonly for the nodes in theneighbouring cells
and only when thedistance is at most dmax
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms17
Grid Version (Fruchterman, Reingold, 1990)
v
subdivide plane by a gird
compute repulsive forcesonly for the nodes in theneighbouring cells
and only when thedistance is at most dmax
Discussionmeaningful idea toimprove runtimeworst-case no advantageQuality loss (e.g.,oscillation dmax)
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms18
Quad-Tree
r0R0 QT
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms18
Quad-Tree
r0
r1 r2 r3 r4
R1 R2
R3 R4
QT
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms18
Quad-Tree
r0
r1 r2 r3 r4
r5 r12
R5
R6
R7
R8 R9
R10 R11
R12
QT
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms18
Quad-Tree
r0
r1 r2 r3 r4
r5 r12
r13 r16
R13
R14
R15
R16
QT
r6
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms18
Quad-Tree
r0
r1 r2 r3 r4
r5 r12
r13 r16
r17 r18
R17
R18
QT
r6
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms19
Properties of Quad-Tree
height h ≤ log sinit
dmin+ 3
2 , here dmin-smallest distancetime and space O(hn)compressed quad-tree in O(n log n) time
r0
r1 r2 r3 r4
r5 r12
r13 r16
r17 r18
r6
sinit
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms20
Forces with Quad-Trees (Barnes, Hut, 1986)
QT
u
r0
r1 r2 r3 r4
r5 r12
r13 r16
r17 r18
QT
u
r6
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms20
Forces with Quad-Trees (Barnes, Hut, 1986)
QT
uσR2
σR3
r0
r1 r2 r3 r4
r5 r12
r13 r16
r17 r18
QT
u
r6
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms20
Forces with Quad-Trees (Barnes, Hut, 1986)
QT
u
σR5
r0
r1 r2 r3 r4
r5 r12
r13 r16
r17 r18
QT
u
r6
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms20
Forces with Quad-Trees (Barnes, Hut, 1986)
QT
u
σR16
r0
r1 r2 r3 r4
r5 r12
r13 r16
r17 r18
QT
u
r6
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms21
Multilevel-Algorithms for Large Graphs
Motivationclassical Spring-Embedder for large graphs are too slowscensitivity to random initialization of node positions
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms21
Multilevel-Algorithms for Large Graphs
Motivationclassical Spring-Embedder for large graphs are too slowscensitivity to random initialization of node positions
GRIP – Graph dRawing with Intelligent Placement(Gajer, Kobourov, 2004)
Approach
top-down graph coarsening/filtrationbottom-up calculation of the layout:clever placement of new nodesforce-based refinement of their positions
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms22
GRIP Algorithm
Input: Graph G = (V,E)
V ← Filtering V = V0 ⊃ V1 ⊃ · · · ⊃ Vkfor i = k to 0 do
foreach v ∈ Vi \ Vi+1 docompute neighbours of vcompute initial position of v
for j = 1 to rounds doforeach v ∈ Vi do
force-based relaxation
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms23
MIS-filtering
sequence of node sets V = V0 ⊃ V1 ⊃ · · · ⊃ Vk ⊃ ∅Vi is (inclusion-) maximal set of nodes, so thatdistance in G between nodes in Vi is ≥ 2i−1 + 1good balance betwen size of a level and depth ofdecompositon
Maximal Independent Set (MIS) filtering
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms24
Computing MIS-Filtering
incremental procedure: given Vi compute Vi+1
select random element v in Viremove all elements from Vi with distance ≤ 2i to vuse BFS from v with search depth 2i
until no further node remains in Vi
Algorithm
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms24
Computing MIS-Filtering
incremental procedure: given Vi compute Vi+1
select random element v in Viremove all elements from Vi with distance ≤ 2i to vuse BFS from v with search depth 2i
until no further node remains in Vi
Depth of Filtration
Algorithm
for the last level k it holds that 2k > diam(G)therefore the depth is O(log diam(G))
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms24
Computing MIS-Filtering
incremental procedure: given Vi compute Vi+1
select random element v in Viremove all elements from Vi with distance ≤ 2i to vuse BFS from v with search depth 2i
until no further node remains in Vi
Depth of Filtration
Algorithm
for the last level k it holds that 2k > diam(G)therefore the depth is O(log diam(G))
Alternativecoarsening with contracting matchings: end vertices of eachmatching edge are contracted (Walshaw, JGAA 2003)
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms25
Level-based Node Placement
Step 1
for each node v ∈ Vi \ Vi+1 find optimal position withrespect to three adjacent nodes Vi+1
Step 2perform force-based refinement, where forces are computedlocally only to a constant number of nearest neighbors in Vi
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms25
Level-based Node Placement
Step 1
for each node v ∈ Vi \ Vi+1 find optimal position withrespect to three adjacent nodes Vi+1
Step 2perform force-based refinement, where forces are computedlocally only to a constant number of nearest neighbors in Vi
Properties of GRIP
intelligent step-by-step calculation starting from a goodlayout and using MIS-filteringsignificantly faster convergencegraphs with > 10,000 nodes in seconds (2004)
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms26
Experimens (Hachul, Junger 2007)
Left: Grid version ofFruchterman Reingold.Right: GRIP
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms27
Other Examples
Lombardi-Spring-Embedder (Chernobelskiy et al. 2012)
edges are circular arcsgoal: optimal angular resolution 2π/deg(v) at each node vadditional rotational forces
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms27
Other Examples
Lombardi-Spring-Embedder (Chernobelskiy et al. 2012)
edges are circular arcsgoal: optimal angular resolution 2π/deg(v) at each node vadditional rotational forces
Metro Maps with Bezier curves (Fink et al. 2013)
model paths as Bezier curvesforces on nodes and control points:lines are distinguishablefew bend pointsfew control points
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms27
Other Examples
Lombardi-Spring-Embedder (Chernobelskiy et al. 2012)
edges are circular arcsgoal: optimal angular resolution 2π/deg(v) at each node vadditional rotational forces
Metro Maps with Bezier curves (Fink et al. 2013)
model paths as Bezier curvesforces on nodes and control points:lines are distinguishablefew bend pointsfew control points
Realistic Node Sizes (Gansner, North 1998)
node positions are adjusted to avoid overlaps
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms28
Summary
Force-based Approaches are
easily understandable and implementableno special requirements on the input graphdepending on the graphs (small and sparce) amazinglygood layouts (Symmetries, Clustering, ...)easily adaptable and configurablerobustscalable
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms28
Summary
Force-based Approaches are
easily understandable and implementableno special requirements on the input graphdepending on the graphs (small and sparce) amazinglygood layouts (Symmetries, Clustering, ...)easily adaptable and configurablerobustscalable
But...usually no quality and running time guaraneesbad choice of starting layout → slow convergencepossibly slow for large graphsfine-turning can be done by experts
Dr. Tamara Mchedlidze · Algorithmen zur Visualisierung von Graphen Force-Directed Algorithms29