Академический Документы
Профессиональный Документы
Культура Документы
Graph Drawing
Computational Geometry
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach
Malte Skambath
zu Lubeck Universitat Institute for Theoretical Computer Science
Summary
February 7, 2012
1 / 46
Outline
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
2 / 46
Introduction
What is Graph Drawing?
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
3 / 46
Challenges
What is a nice graph?
Visualization of the graph should have nice look No precisely denition. Criteria on nice drawings
Symmetries Less crossing as possible Less bends as possible
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
4 / 46
Types of drawings
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
(a)
(b)
(c)
(d)
MinCostFlow-Problem
Summary
Figure : Types of drawings: a polyline (a), straight-line (b) and (c) an orthogonal drawing of K3,3 ; (d) upward drawing
5 / 46
Motivation
Is it useful for me?
state-machines UML class diagrams electrical circuits / chip-design trafc-nets (e. g. bus map)
rtlenburger Str. rd-Wagner-Str.
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Graph
Node
Mozartstr.
Edge
PlanarGraph
Faces
Friedenstr. 1 Adolf40 str. Wickedestr. 39 Gustav- 30 Fackenburger RadbruchAllee 32 Beckergrube Platz 32 31 15 Ehren- Z 40 Breite Str./ friedhof LindenArcaden 12 Schulstr. 11 Meierstr. 3 Stadtche Tpferweg 30 12 Geschw.-S theater UnterGroe trave Gustav-Adolf-S Burgstr. RoeckZOB/ 30 31 39 Schssel3 Hauptbahnhof str. buden Heinrichstr. 39 40 8720 Koberg 15 31 HolstentorDrger- 4 LachswehrLauerho 21 e platz park 11 StadtKatharineum allee 11 4 werke 10 Falkendam m Schenk 8720 5 15 5 Fleischhauerer DrgerKohlm arkt str. An der werk 15 32 10 Falkenwiese Gneisenaustr. 1 2 6 7 9 16 (17) Wahm str. 2 Goeben3 Linien 15 u. 32 5 Percevalstr. Sandstr. str. WielandUm leitung wegen MarliMeesenNeubau str. Krhenring ring Hansering Blanckstr. Knigstr. Possehlbrcke str. 11 4 bis 2014/15 Fegefeuer Am 5 Kaufhof 4 Moltkestr. MoltkeLutherkirche H Bertram shof Hxtertorallee platz Wisbystr.
Drgestr.
10
LBECK HBF
R1 R2
Summary
keine Bedienung
Welsbachstr.
Stadthalle
15
Stresem annstr.
Kernzone 6000
Pensebusch Trk
6 / 46
Force-directed approach
Force-directed approach
Spring Embedder
Used for straight line drawings Model the graph-vertices and edges as physical objects with forces Distance of adjacent vertices (v , w ) should be nearly the same distance d (v , w ) No overlapping vertices
Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
7 / 46
Force-directed approach
1. Generate random representation of G with random positions p(v ) for v V 2. Calculate forces between each pair of vertices vi , vj : f (vi , vj ) 3. Calculate resulting force f (v ) for each node v V : f (v ) w V \{v } f (v , w ) 4. Update positions p(v ) = p(v ) + f (v )
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
8 / 46
Spring Embedder
Remember: we want a unit distance d (v , w ) if v , w are adjacent Model edges as springs with a unit length unit length no force attracting force (adjacent vertices): fa = ca log d cr repelling force (non-adjacent vertices): fr = 2 d stepwise simulatable fa (v , w ), (v , w ) E f (v ) = (p(w ) p(v )) fr (v , w ), (v , w ) E w V \{v } p(v ) := p(v ) + f (v )
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
9 / 46
Spring Embedder
Sample
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
10 / 46
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
11 / 46
Simulated Annealing
Goal: optimize drawing to selected criterias No forces, but physical model Inspired by cool-down process in liquids Dene an energy-function E : R Low value E ( ) ts many criteria High temperature T high propabilty P nding a better conguration Low energy value E ( ) low propability P nding a better conguration
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
12 / 46
Simulated Annealing
Algorithm 1: Simulated Annealing Graph Drawing input : A graph G = (V , E ), an initial temperature T output: A straight-line drawing of G begin Create initial drawing/conguration with random pos. for each vertex v V ; while do Choose a new conguration from the neighborhood of ; Let E and E be the energy values of and ; if E < E or with a probability of e(E E )/T then ; Decrease T
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
13 / 46
Energy function
should depend on the criteria low time complexity Example (by R. Davidson and D. Harel.): f = 1
i =j
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
+ 2
nV
+ 3
eE
d (e)
Summary
+ 4 crossings + 5
eE ,nV
d (n, e)
14 / 46
How can we dene the neighborhood? change the position of a single node in
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
15 / 46
Simulated annealing
example
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
16 / 46
Crossing Minimization
Goal: reduce number of crossings in a drawing of a non-planar graph G We know: planar graphs can be drawn without crossings Approximate Graph as a planar graph Idea: convert non-planar graphs into planar graphs and replace non-removable crossings as virtual vertices Planarizataion approach: create a planar embedding of the new graph
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
17 / 46
Planarization Approach
1. Find maximum planar subgraph and embedding, without crossing 2. Create embedding of the graph 3. Insert the non-planar edges with a minimum number of crossing, use crossings as virtual vertices
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
18 / 46
Planarization Approach
1. Find maximum planar subgraph and embedding, without crossing 2. Create embedding of the graph 3. Insert the non-planar edges with a minimum number of crossing, use crossings as virtual vertices Problem Finding a maximum-planar subgraph is N P -hard . trade off nd a maximal planar subgraph
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
18 / 46
Algorithm 2: Maximal planar subgraph input : a graph G = (V , E ) output: a maximal planar subgraph G = (V , E ) of G begin E = ; while there is an edge e E \ E that G = (V , E {e}) is planar do E E { e }; return G ;
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
19 / 46
Denition A dual graph DG = (F , E ) of a planar graph G = (V , E ) is a (multi-)graph where F represents the faces in a planar embedding of G. Each pair f1 , f2 F of adjacent faces is splitted by an edge in G. E (F ) E (G)
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
20 / 46
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
21 / 46
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
22 / 46
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
23 / 46
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
k+1
k+1
Summary
24 / 46
Problem: for some edges the graph can easily be modied to reduce number of crossings if the 2 vertices of the edge are in different blocks of a parallel substructure switch the order to decrease number of crossings
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
25 / 46
SPQR-tree
Force-directed approach
Spring Embedder
s e t
(a) trivial case (b) parallel case (c) series case (d) rigid case
Simulated Annealing
e e
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
26 / 46
SPQR-tree
b a d c e g n f h l k m i o j p
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
27 / 46
SPQR-tree
a
a c d f h k
b e g n i l j m
f d e h h h h h k l m m h j h d
d e e e
c e
Force-directed approach
Spring Embedder Simulated Annealing
e e n n j j j i j j n n n
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
o p
28 / 46
SPQR-trees
a d d d f h h h h h k l m m j h i h j j j j j e e e n n n o p e n e c e e g n b
R P S P R S P S S P R P S
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
29 / 46
SPQR-trees
a d f h k l b c e g n i j m R S P S o p R P S P S P R P S
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
30 / 46
SPQR-trees
g e d b c a f i h l j k m n R o P p S P R S P S S P R P S
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
31 / 46
Orthogonal Drawing
(E ) for each edge e E is a set of orthogonal lines (v ) for each vertex v V is a point in R2 Denition We call an orthogonal planar drawing of G if 1. v , w V : (v ) = (w V ) w = v (invective) 2. e = (v , w ) E : (v ), (w ) are endpoints of (e) 3. e1 , e2 E : e1 = e2 (e1 ), (e2 ) only intersect at a point (v ) of a common vertex v (if exists)
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
32 / 46
Orthogonal Drawing
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
two different planar orthogonal representations , of the same Graph G, but with a different number of edges and the same faces
MinCostFlow-Problem
Summary
33 / 46
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach
If we have a planar representation of a planar Graph, keeping the the same faces we can minimize the number of bends with solving a minimum cost ow problem.
Summary
34 / 46
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
(w ,v )A f (w , v )
aA c (a)f (a)
is minimal.
35 / 46
Force-directed approach
v4
v5
Spring Embedder
Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
v1
v2
v3 (v3 , v5 ) = 1
dene labels (v , w ), (v , w ) for each edge (v , w ) in G: : (v , w ) E #of L-bends in ((v , w )) : (v , wi ) E betw. ((v , wi ))and((v , wi +1 ))
Summary
36 / 46
Remember: We want to minimize the total number of bends on edges in the drawing (G). The total number is (v ,w )E (v , w ) + (w , v ). So the goal is: minimize (v ,w )E (v , w ) + (w , v ) 1 1 2 1 1 1 2 1 1 1
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
37 / 46
Theorem The sum of angles(at vertices or bends) around an inner/outer face f F is: (deg(f ) + #bends 2) This implies: ((v , w ) + (w , v ) (v , w )) = 2 deg(f ) 4
(v ,w )E (f )
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
38 / 46
((v , w ) + (w , v ) (v , w )) = 2 deg(f ) 4
(v ,w )E (f )
Types of drawings
Force-directed approach
Spring Embedder Simulated Annealing
1 1 1 1 1 2 1
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
Let the face-to-face edges (producers of bends on an edge) get edges in the ow networks with costs 1
39 / 46
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
demands in the ow-network N : 2 deg(x ) 4 , x F (inner / outer face) b(x ) = : 4 ,x V capacities: e A : u (e) = ; e AF : l (e) = 0; e AF : l (e) = 1 costs: eF AF : c (eF ) = 1; e AF : c (e) = 0
Summary
40 / 46
Assign ow
Given a ow f : E N f (v , fv ,w ): angle() at node v in face fv ,w left of (v , w ) f (f1 , f2 )e : #LeftBends ( ) on the edge (f1 , f2 )e between the faces f1 and f2 A ow f is a valid model for a valid drawing if: for all nodes v : b(v ) = for all faces f :
( (v , w ) + (w , v ) (v , w )) = 2 deg(f ) 4
(v ,w )E (f )
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
(v ,w )E
f (v , w ) = 4
Summary
inow outow
A valid ow implies a valid graph representation A cost-minimal ow implies a bend-minimal graph representation
41 / 46
Assign ow
Given a ow f : E N f (v , fv ,w ): angle() at node v in face fv ,w left of (v , w ) f (f1 , f2 )e : #LeftBends ( ) on the edge (f1 , f2 )e between the faces f1 and f2 A ow f is a valid model for a valid drawing if: for all nodes v : b(v ) = for all faces f :
( (v , w ) + (w , v ) (v , w )) = 2 deg(f ) 4
(v ,w )E (f )
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
(v ,w )E
f (v , w ) = 4
Summary
inow outow
A valid ow implies a valid graph representation A cost-minimal ow implies a bend-minimal graph representation
41 / 46
Assign ow
Given a ow f : E N f (v , fv ,w ): angle() at node v in face fv ,w left of (v , w ) f (f1 , f2 )e : #LeftBends ( ) on the edge (f1 , f2 )e between the faces f1 and f2 A ow f is a valid model for a valid drawing if: for all nodes v : b(v ) = for all faces f :
( (v , w ) + (w , v ) (v , w )) = 2 deg(f ) 4
(v ,w )E (f )
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
(v ,w )E
f (v , w ) = 4
Summary
inow outow
A valid ow implies a valid graph representation A cost-minimal ow implies a bend-minimal graph representation
41 / 46
to proof:
v W
b(v ) = 0 b(v ) + b (f )
f F
Types of drawings
Force-directed approach
Spring Embedder Simulated Annealing
b (v ) =
v W v V
Crossing Minimization
= |V |4 +
(2 deg f + 4) 2 deg fo 4
f F \{fo }
= |V |4 + (|F| 2)4 2
f F
(deg f )
Summary
42 / 46
Bend Minimization
example
Force-directed approach
Spring Embedder Simulated Annealing
-14 3 -4 3 2 1 2 -2 3 3 -4 2 3 2
-14 1 -2 2 3
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
43 / 46
Summary
graph drawing is a wide area with many problems most problems are N P hard problems depend on the type of drawings and the slected criterias good approximation is possible for many problems combination of algorithms may be possible there exists many tools for graph drawing
1. 2. 3. 4. yEd GraphViz Gephi Tulip
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
44 / 46
GraphViz
example
circo-layout:
twopi-layout:
graph G{ 2 node[label=""]; 3 a1 -- a2; a1 -4 a1 -- a4; 5 a1 -- a5; a1 -6 a2 -- a3; a2 -7 a2 -- a5; a2 -8 a3 -- a4; a3 -9 a3 -- a6; 10 a4 -- a5; a4 -11 a5 -- a6; 12}
1
Types of drawings
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
45 / 46
yEd
Force-directed approach
Spring Embedder Simulated Annealing
Crossing Minimization
Planarization Approach Dual graph SPQR-tree
Summary
46 / 46