16
Bachelor-Seminar: Computational Geometry Graph Drawing Malte Skambath Universität zu Lübeck [email protected] February 7, 2013 1 Introduction Graph drawing is an area of mathematics and especially computer science. It is the problem on constructing geometric representations of graphs and needs to be used in the application field of information visualisation. The area of applications using graph drawing algorithms includes software engineering (UML-diagrams), chip-design (electrical circuits), visualization of traffic nets, etc. 1.1 Types of graph drawings There are many possible ways to draw a graph. Mostly the vertices are drawn as points in a 2D grid and the edges are represented as connected lines between the vertices. Different types of drawings exists for different ideas on how to draw a graph. Here are some examples for different types of drawings Straight-line drawing In a straight line drawing each vertex is a 2D point and the edges are a straight lines between the to points of the vertex of an edge. Polyline drawing In a polyline drawing each vertex is a 2D point and the line between two vertices consists of at least one straight line-segments. Orthogonal drawing An orthogonal drawing is a polyline drawing, where the angles between to lines or line-segments must be π/2or 3π/2. (a) (b) (c) (d) Figure 1: Types of drawings: a polyline (a), straight-line (b) and (c) an orthogonal drawing of K 3,3 ; (d) upward drawing; taken from [9] 1

Handout Presentation 7-02-13 Graph Drawing

Embed Size (px)

DESCRIPTION

Seminar Computational Geometry WT1213 - Graph Drawing (Handout)

Citation preview

Page 1: Handout Presentation 7-02-13 Graph Drawing

Bachelor-Seminar: Computational Geometry

Graph Drawing

Malte SkambathUniversität zu Lübeck

[email protected]

February 7, 2013

1 Introduction

Graph drawing is an area of mathematics and especially computer science. It is theproblem on constructing geometric representations of graphs and needs to be used inthe application field of information visualisation. The area of applications using graphdrawing algorithms includes software engineering (UML-diagrams), chip-design (electricalcircuits), visualization of traffic nets, etc.

1.1 Types of graph drawings

There are many possible ways to draw a graph. Mostly the vertices are drawn as points ina 2D grid and the edges are represented as connected lines between the vertices. Differenttypes of drawings exists for different ideas on how to draw a graph. Here are someexamples for different types of drawings

Straight-line drawing In a straight line drawing each vertex is a 2D point and theedges are a straight lines between the to points of the vertex of an edge.

Polyline drawing In a polyline drawing each vertex is a 2D point and the line betweentwo vertices consists of at least one straight line-segments.

Orthogonal drawing An orthogonal drawing is a polyline drawing, where the anglesbetween to lines or line-segments must be π/2, π or 3π/2.

(a) (b) (c) (d)

Figure 1: Types of drawings: a polyline (a), straight-line (b) and (c) an orthogonaldrawing of K3,3; (d) upward drawing; taken from [9]

1

Page 2: Handout Presentation 7-02-13 Graph Drawing

Upward drawing An upward drawing is a polyline drawing of an acyclic digraphwhere each edge is drawn upward in vertical direction.

1.2 Criteria on nice graphs

The basic goal of Graph Drawing is the drawing of nice representations of graphs whichbrings us the basic question: What is a nice graph? Of course we cannot describe thisdirectly with mathematical methods because it depends on subjective impressions andon the field of applications, so we have to describe a graph drawing with some definedproperties that could define a nice graph. Here are some examples of properties that canbe used as criteria for nice graphs:

• Crossings: the total number of crossings of edges in a drawing

• Edge length: the maximum, minimum or sum of edge-lengths in a drawing

• Number of bends: the total number of bends in a poly-line or orthogonal drawing

• Angular resolution: the smallest angle formed by two edges at a same vertex

• Symmetries: symmetrical structures if possible

2 Force directed approach

Force-directed approach methods are algorithms for straight-line drawings inspiredby physical models for drawing graphs. The basic idea is modelling vertices and edges ofa graph as physical objects with properties like velocity, acceleration, forces, etc. andsimulate physical processes starting with random initial drawings and finding a low energydrawings. Algortihm 1 is a general algortihm for force-directed approach Algorithms.

Algorithm 1: General Forced-Based Algorithminput : A graph G = (V,E), the number of steps N , parameter ∆output : A straight line drawing Γ : V → R2

beginGenerate initial represantation Γ with random positions;for i := 1→ N do

for v ∈ V do~f(v) = 0;for w ∈ V do

~f(v, w) = CalcForce(G,Γ, v, w);~f(v) = ~f(v) + ~f(v, w);

for v ∈ V doΓ(v) = Γ(v) + ∆~f(v)

return Γ

2

Page 3: Handout Presentation 7-02-13 Graph Drawing

2.1 Spring Embedder

The spring embedder is a force-directed approach method where edges are modelled assprings between their adjacent vertices. Each spring should have a nature unit length,what means that a spring would attract two adjacent vertices until they have a unitdistance. Therefore for every pair of points v, w of adjacent vertices an attracting forceis defined with fa = ca log d(v, w) where d is the euclidean distance. Additional to theattracting force a repelling force fr = −cr/d(v, w)2 is used to get a higher distancebetween two non-adjacent vertices to prevent overlapping nodes.Now we can stepwise calculate for each vertex the sum of forces as vector to get a

greater than unit length: attracting force is positiveunit length between the vertices: no attracting forcesmaller than unit length: attracting force is negative

Figure 2: a spring embedder between two adjacent nodes approximates a unit length

resulting force on every vertex point and simulate the force by adding the force vector~f(v) to the current position p(v) of the vertex v: p(v) := p(v) + ∆~f(v) [3].

Algorithm 2: Spring Embedder CalcForceinput : A graph G and a representation Γ, two vertices v, w ∈ V (G)output : A force vector ~f(v, w)

beginCreate direction vector ~a from Γ(v) to Γ(w) of length 1;if (v, w) ∈ E(G) then

return ~a · ca log d(v, w) // use attracting force fa

elsereturn ~a · (−cr/d(v, w)2)// use repelling force fr

2.2 Simulated Annealing

One problem of using force-based algorithms with simulation is that the representationwouldn’t get better when a stable state is reached (although there could be a somebetter ones) when all forces are compensating each other. A possible way is to use it asinteractive algorithm, where a user can modify the representation. Another possibility

(a) (b)

Figure 3: Two different drawings of the same graph created with force directed approachmethod; both shows stable drawings but obviously (b) is the better drawing

3

Page 4: Handout Presentation 7-02-13 Graph Drawing

(a) initial configuration (b) end configuration

Figure 4: Example of simulated method, taken from [2]; Although this algorithm doesn’texplicit planarize a graph the result is quite good.

not using forces directly is using a simulated algorithm inspired of a physical cool-downprocess: when liquids cool down the atoms have time to reach a local minima energystates. This effect is usable for different algorithms not only in graph drawing wherewe can defining an energy function, describing the evaluation of a system configuration,for straight line drawings the positions of the vertices. Algorithm 3 shows a general

Algorithm 3: Simulated Annealing Graph Drawinginput : A graph G = (V,E), an initial temperature Toutput : A straight-line drawing of G

beginCreate initial drawing/configuration σ with random pos. for each vertexv ∈ V ;while do

Choose a new configuration σ′ from the neighbourhood 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

simulated annealing algorithm for graph drawing. Implementing such an algorithmwe need to define a energy-function and how to choose a new configuration σ of theneighbourhood. The neighbourhood of a configuration σ should be a set of configurationswith only small differences to σ. A good variant is only changing the position of a singlenode and let the distance between the new and old position be smaller than a maximumradius that is also shrinking with the temperature.

Using simulated annealing can produce good results with a useful energy function. Theenergy function can depend on some criteria for nice graphs like the node distances andnumber of crossings. In [2] a nice method is shown using an energy-function dependingon the crossing number, the distances between vertices, vertices and non-incident edgesand area bounds. In compare with force-directed approach it is possible to approachspecified criteria for nice graphs. But important defining a new energy function, is tokeep a low complexity, because the algorithm can get slow for huge graphs.

4

Page 5: Handout Presentation 7-02-13 Graph Drawing

(a) (b) (c) (d)

Figure 5: Planarization approach: (a) initial drawing; (b)partition edges into planarand non-planar (dashed) edges; (c) create planar embedding of planar graph; (d) insertnon-planar edges with low number of crossings and replace crossings to virtual vertices

3 Crossing minimization

One important criteria for a nice graphs is the number of crossings of lines, representingthe edges of the graph. Of course for a planar graph it is possible to draw it withoutcrossings by definition, but what when we have a non-planar graph. How can we reducethe number of crossings then? The basic idea is: Finding the maximum planar embeddingof the graph and insert the left edges with minimum number of crossings and make themvirtual vertices of a new planar graph.

Finding a maximum planar subgraph1 is a NP-complete problem, so we need someheuristics to find a maximal planar subgraph2 [5, 9]. A trivial method finding a maximalplanar subgraph is inserting edges of a graph into an empty subgraph until there are noedges left that the subgraph keep planarity3.

Assume we have found a planar subgraph and its drawing. If we want to insert anedge with creating the least possible number of nodes we have to find a shortest wayover the faces of the existing drawing. To be able to implement this efficiently we needsome good data-structures.

3.1 Dual graph

A dual graph D = (F , E) is a graph which can have loops and multiple edges of a planarGraph G = (V,E) if there exists a drawing of G where each face f of the drawing isa vertex in D and for each pair of adjacent faces fi, fj ∈ F over an edge e ∈ E(G)(fi, fj)e ∈ E(D) is an edge in D. Figure 6 show an example for a graph with its dualgraph. The dual graph for a planar graph exists for each possible planar embedding so itis not unique.

3.2 Insert non-planar edges

Assume we have now a maximal planar graph drawing of G and we want to try to insertthe left edges into the drawing with a small number of crossing. One possible way givenan edge (v, w) to insert is finding the shortest path pv,w between v and w in the dualgraph. Because of v, w aren’t in the dual graph and have more than one single adjacentface in the DG we modify the dual graph to the extended dual graph DG containing

1A maximum planar subgraph is a planar subgraph of a graph with the highest number of edges2A maximal planar subgraph is a planar subgraph where no edge of a graph can be inserted without

loosing planarity3As shown in [5,6] planarity testing and finding an optimal planar sub graph can be done in linear

time

5

Page 6: Handout Presentation 7-02-13 Graph Drawing

(a) (b)

Figure 6: A graph G (a) and G with its dual Graph DG (b)

v, w and for each adjacent face f of v/w an edge (v, f)/(f, w) use all adjacent facesinstead. [5]

Algorithm 4: Insert non-planar edgeinput : A planar graph G = (V,E) and its embedding with the dual graph

DG = (F , EF ), the edge e = (v, w) 6∈ E(G) to insertoutput : A new planar Graph G′ with virtual nodes

beginLet EF ← EF ∪ {(x, f)) | (x = v ∨ x =)w ∧ f is adj. face of x in the embedding of G};Create extended dual graph DG = (F ∪ {v, w}, E) ;p = e1, e2, . . . , ek ← ShortestPath(DG, v, w);for i := 1→ k do

e = (x, y)← ei;if x ∈ F ∧ y ∈ F then

Split corresponding edge e = (a, b) ∈ E(G) of e ∈ EF toe1 = (a, n), e2 = (n, b);and add virtual node to G.;ye ← n;Insert a new edge (xe, ye) in E(G);xe ← ye;

if x = v thenprevious node xe ← v;xe ← v first node of next edge.

if y = w thenInsert a new edge (xe, w) in E(G);

return G

In figure 7 it is easy to see that if pv,w is the shortest path of the length k betweenv, w in the extended dual graph the number k − 2 of non-vertex-face edges on this pathis the minimal number of crossings created by insert the edge (v, w) to the embedding.Algorithm 4 inserts an edge into a planar path graph by finding the shortest path inthe extended dual. Until there are some planar edges this method can be used also tocreate a maximal planar fixed embedding to build up the dual graph for further use whilefinding the maximal planar subgraph. If there is no shortest path of length 2 we haveonly paths that contains face-to-face edges what means there must be a crossing in the

6

Page 7: Handout Presentation 7-02-13 Graph Drawing

(a) (b)

Figure 7: Insert a non-planar edge in a fixed drawing with a minimum number ofnew crossings; (a) shows the graph and the new edge (dashed); In (b) is the dualgraph(dotted/dashed) and the shortest path (dashed) between adjacent faces of theend-nodes of the new edge.

(a) (b) (c)

Figure 8: Insert a non-planar edge step by step: the dotted graph is part of the dualgraph; each step the next face on the shortest path in the dual graph is split and a virtualvertex is added on the next edge

fixed embedding.To implement the complete process of insert every non-planar edge it would be good

if we don’t have to calculate the new dual graph after each edge-insertion. Figure 8shows stepwise the insertion process and the changes on the dual graph. We can see it isonly necessary to split a face of the dual graph insert a new edge on the path, what ispossible in constant time and for every time splitting two corresponding edges have toreplace one edge in the dual graph.

Of course using the dual graph is not an optimal method because it is only a greedystrategy and the order of the edges can generate different dual graphs, so there are alsovery bad graph representations we will get a high number of crossings (see figure 9)although a comparative small number is possible.

As shown in [5] there is a possibility to reduce the number of crossings by inserting anedge with a small number of crossings can be improved by using SPQR-trees describingthe structure of biconnected planar graphs without using fixed embeddings of the graph.The basic idea behind this is changing the embedding on adding a non planar edge andimproving the embedding of parallel substructures, that are biconnected components ofthe embedded graph. As figure 10 shows if a new edge between two subcomponents ofthe biconnected substructure has to be inserted the order of the components can improve

7

Page 8: Handout Presentation 7-02-13 Graph Drawing

k

k + 1

e

(a)

k

k + 1

e

(b)

Figure 9: Insert edge e using the dual graph method can produce bad results: In the dualgraph of the left representation (a) you get k+ 1 crossings but in the right representation(b) only 1 crossing [5]

1 2 3

(a)

2 1 3

(b)

Figure 10: A biconnected component and a new edge between two subcomponents. Theorder generates in (b) a lower number of crossings than (a).

the number of crossings in the embedding.

3.3 SPQR trees

An SPQR-tree is a tree data structure describing a decomposition of a biconnected graph,representing its triconnected components. As shown in [7] an SQPR tree can be createdin linear time. We can use SPQR trees for improving the crossing minimization problemfor single edge insertion instead to find only shortest paths in the dual graph of a fixedembedding like the example in figure 10 shows.

An SPQR-tree of a biconnected graph G consists of 4 different types of nodesS, P,Q,R, each node has a skeleton graph representing the structure of the graph theedges of a skeleton represents connected subgraphs of the graph.

Series Case (S) An S-node associates a cycle skeleton it represents a biconnectedsubgraph of at least three components.

Parallel Case (P ) If G contains a split pair 4 s, t ∈ V (G) that G consists of maximalconnected components G1, . . . , Gk with exactly s and t as common vertices and at leastone of the split components has no cut vertex5 then G is represented by a P -node asskeleton with k edges.

4a split pair in a biconnected graph G are two nodes that G without them consists of more components5a cut vertex v is a vertex of a 1-connected component C that C without v consists of two components

8

Page 9: Handout Presentation 7-02-13 Graph Drawing

e

s

t(a) trivial case

e

(b) parallel case

e

(c) series case

e

(d) rigid case

Figure 11: The four different types of nodes in an SPQR-tree, e is a virtual edgerepresenting the rest of the graph

Trivial Case (Q) If G consists of two parallel edges between a split-pair s, t the Gwith its embedding is represented by a single Q-node. A Q-node is only necessary intrivial graphs for single edges in other graphs it would present single edges.

Rigid Case (R) A R-node represents a triconnected component, that consist of atleast three edges and can’t be one of the other nodes. A planar skeleton of an R-nodehas a unique embedding except of mirroring.

ab

c

de

f

h

g

i

j

kl

m

n

op

(a)

a bc

d e

d e

d e

f h

e

h

e

h j

n

h j

h

j

m

lk

h

m

e n

e n

g

n

j

n

j

po

h

j

i

(b)

R

P

S

P S

P

S

PR

PS

S

R(c)

Figure 12: SPQR-decomposition: a graph (a); its decomposition into SPQR skeletonsdotted lines are virtual edges representing other components in the graph normal edgesare solid lines; the corresponding SPQR-tree of the graph without Q-nodes

See figure 11 for the sample skeleton graphs for each node type. Figure 12 showsan example graph with its decomposition into skeletons and its SPQR-tree. In a givenSPQR-tree with the corresponding skeletons of a graph the graph can be reproduced bymerging two skeletons of adjacent nodes in the SPQR tree. A detailed description andalgorithms using SPQR-trees in crossing minimization can be found in [5].

9

Page 10: Handout Presentation 7-02-13 Graph Drawing

4 Orthogonal Bend Minimization

Another nice criteria for nice drawings is a low number of bends in this case we willonly look at planar orthogonal drawings. Here we will only look at orthogonal planardrawings of graphs with a maximum degree of 4.

(a) (b)

Figure 13: two different orthogonal drawings Γ,Γ′ of the same planar graph G with adifferent number of bends

Definition 4.1 We call Γ where Γ(e ∈ E) is a set of orthogonal lines and Γ(e ∈ V ) is apoint in R2 an orthogonal planar drawing of G if

1. ∀v, w ∈ V : Γ(v) = Γ(w)⇔ w = v (injective)

2. ∀e = (v, w) ∈ E : Γ(v),Γ(w) are endpoints of Γ(e)

3. ∀e1, e2 ∈ E : e1 6= e2 ⇒ Γ(e1),Γ(e2) only intersect at a point Γ(v) of a commonvertex v (if exists)

Figure 13 shows two different orthogonal drawings of the same graph and figure 14 showssample valid and invalid substructures of planar orthogonal drawings.

(a) (b) (c)

Figure 14: substructures of orthogonal drawings; (b) shows an invalid structure becausetwo line-segments of different edges are crossing

If we have a non-planar graph G but with a maximum degree of 4, we can convert itinto a planarized graph as described in paragraph 3. Finding a bend-minimal orthogonaldrawing of a graph G is an NP hard problem, but with a given drawing with a fixedorder of edges at the vertices it makes it much easier and the problem can be solved bysolving the MinCostFlow-Problem of a Flow-Network. The first time this method waspresented in [8].

For further considerations we need some labels for the edges (v, w) ∈ E: α representingthe angle at node v between (v, w) and the next edge in anticlockwise order as unitnumber for an angle of π2 and τ(v, w) as the number of left bends on the edge (v, w) formv to w (see figure 15).

10

Page 11: Handout Presentation 7-02-13 Graph Drawing

v1 v2 v3

v4 v5 τ(v3, v5) = 2/τ(v5, v3) = 1

α(v3, v5) = 1

α(v5, v3) = 2

Figure 15: Labels for the edges: τ(v, w) or τ(w, v) is the number of left- or right-bendson the edge v to w;α(v, w) are the unit-angle of π2 between the edge (v, w) and the nextedge in anticlockwise order at v [1]

4.1 MinCostFlow Problem

We already said that the problem of bend-minimization for orthogonal planar graphscan be solved with a MinCostFlow Problem. So first we have to define what exactly aMinCostFlow-Network and the MinCostFlow-Problem is.

Definition 4.2 A min-cost flow network N = (D, l, u, b, c) consists of

• a directed (multi-)graph D = (W,A)

• lower and upper capacities l : A→ N0, u : A→ N0 ∪ {∞}

• node demands b : W → Z

• costs c : A→ N0.

f : A → N is an integer flow on N if l(a) ≤ f(a) ≤ u(a) ∧ b(v) =∑

(v,w)∈A f(v, w) −∑(w,v)∈A f(w, v)

A flow f is a min-cost-flow if the costs of the flow∑

a∈A c(a)f(a) is minimal.

A node v with demand b(v) > 0 is called source and a node v with a demand b(v) < 0is called sink.

4.2 Reduce the MinBend Problem to the MinCostFlow Problem

Now we have to reduce the bend-minimization of an orthogonal planar drawing withfixed order to a min-cost-flow problem, but before defining a flow-network to have amodel on an orthogonal planar drawing we need some constraints to be able to force avalid flow in the network mapping a flow to a valid drawing.

Lemma 4.1 The sum of angles(at vertices or bends) around an inner/outer face f ∈ Fis:

π · (deg(f) + #bends∓ 2) (1)

This can be reformulated as:∑(v,w)∈E(f)

(α(v, w) + τ(w, v)− τ(v, w)) = 2 deg(f)∓ 4 (2)

where E(f) are the incident edges of f

11

Page 12: Handout Presentation 7-02-13 Graph Drawing

Proof First we show that the formula (1) is correct: The sum of angles around aninner/outer face including the angles vertices is π

2 (1l + 3r + 2vo), where l, r is the totalnumber of left/right bends and vo is the number of vertices with an angle of π (no bend).By elementary geometry we know l = r ± 4⇔ r = l ∓ 4. This implies

π

2(1l + 3r + 2vo) = π(vo + 1/2(1l + 3r))

= π(vo + 1/2(1l + 2r ∓ 4))

= π(vo + l + r ∓ 2)

Now we know the total number of left/right bends is the number of left/right-bends at avertex vL/vR plus the number of left/right bends on an edge bL/bR. So we can show thecorrectness of (1):

π(vo + l + r ∓ 2) = π(vo + vL + vR + bR + bL ∓ 2)

= π(#vertices/edges around f + #bends∓ 2)

= π(deg f + #bends∓ 2)

Now we will proof the imply to formula (2):Of course the sum of angles around an inner/outer face f is:

φ(f) :=π

2(

∑(v,w)∈E(f)

(α(v, w) + τ(v, w) + 3τ(w, v))

As we just have shown φ(f) = π · (deg(f) + #bends∓ 2) so we can assume:∑(v,w)∈E(f)

(α(v, w) + τ(v, w) + 3τ(w, v) = 2 deg(f) + 2#bends∓ 4

Obviously the number of bends is the sum of right- and left-bends around the face:

#bends =∑

(v,w)∈E(f)

(τ(v, w) + τ(w, v))

Now it is easy to see that this finally implies

2 deg(f)∓ 4 =∑

(v,w)∈E(f)

(α(v, w) + τ(v, w) + 3τ(w, v)− 2(τ(v, w)− τ(w, v)))

2 deg(f)∓ 4 =∑

(v,w)∈E(f)

(α(v, w) + τ(w, v)− τ(v, w))

Formula (2) is now a useful constraint we can use to check for a valid drawing. Tocreate a useful flow-network now N = (DG, u, c, b) remember we want to minimize thetotal number of bends on the edge representations. So the costs of a flow network haveto correspond to the number of bends on an edge. To do this we define a subnetworkDF of our final network with bi directional edges, that are edges in the dual Graph ofthe orthogonal embedding and a subnetwork between the faces and the vertices. Also weneed consumers and producers for our flow network and because a vertex has an angle

12

Page 13: Handout Presentation 7-02-13 Graph Drawing

21

1

(a)

1

2 1

1

1

1

1

(b)

Figure 16: Angles around vertices and on edge-segments; (a) around each vertex thereis an angle of 2π or 4 unit angles(π/2); (b) each additional left/right-bend on an edgeincrease the number of right/left-bends or increase / decrease the angle at vertices arounda face)

(a) (b)

Figure 17: An Illustration of the min-cost-flow network for bend minimization [1]: thenetwork consists of a bi-directed network DF (a) with costs 1 and a uni-directed network(b) with edge-costs 0

of 2π around and between each pair of adjacent faces it needs a minimum angle of π/2we define that each vertex v ∈ V has a demand b(v) = 4 with a lower bound l(e) = 1for every outgoing edge. Finally the consumers are the faces: By Lemma 4.1 (2) weknow for every face f : 2 deg(f)∓ 4 =

∑(v,w)∈E(f) (α(v, w) + τ(w, v)− τ(v, w)), so we

choose order b(f) = −2 deg(f)± 4. Figure 17 shows the resulting min-cost-flow networkN consisting of a bidirected and a unidirected subgraph.

Now with our constraints it is necessary to check if the constructed flow-cost-networkis valid and solvable. For this we have to proof the following Lemma.

Lemma 4.2 The constructed flow network N = (DG, u, c, b) with D = (V ∪ F , E ∪

{(v, f) ∈ V×F | v is vertex around face f}) with the demand b(x) =

{4 , x ∈ V−2 deg x± 4 , x ∈ F

is a valid and solvable flow-cost-network

Proof Because of the structure of this flow network without upper bounds, only lowerbounds from sources to sinks and the boundless strongly connected subnetwork DFcontaining all sinks so they are connected we have only to show that the flow is possibleby showing that the sum of demands is equal to 0.

13

Page 14: Handout Presentation 7-02-13 Graph Drawing

So we have to show that∑

x∈ V ∪F b(x) = 0:∑x∈V ∪F

b(x) =∑v∈V

b(v) +∑f∈F

b(v)

= 4|V |+∑

f∈F\{fo}

(−2 deg f + 4)− 2 deg fo − 4

= 4|V |+ (|F| − 2)4− 2∑f∈F

(deg f)

= 4|V |+ (|F| − 2)4− 4|E|= 4(|V |+ |F| − |E| − 2)

We know our orthogonal drawing is planar then Euler’s formula for planar graphs|V |+ |F| − |E| − 2 = 0 implies

∑x∈ V ∪F b(x) = 0.

Knowing that a valid flow is calculable we can now reinterpret the flow with a validorthogonal drawing where the bend number is equal to the costs of the flow. We choosefor an edge e = (v, w) ∈ E(G) the number of right edges τ(e) = f((f1, f2)e) where f1and f2 are the left and right faces corresponding to e. And the angle α(v, w) be the flowf(v, f) where f ∈ F is the next face after (v, w) in anticlockwise order.

Lemma 4.3 A valid flow f induces a valid graph representation Γ with f(v, f) as angleat v ∈ V at f ∈ F and f((f1, f2)e) as the number of left-bends on edge e ∈ E betweenf1, f2 ∈ F .

Proof We know we have a valid geometrical representation if for all vertices the flowgenerates an angle sum of 2π and no angle of 0 and for all faces f the formula (2) ofLemma 4.1 is correct:

The angle-sum for a vertex v ∈ V is π2

∑(w,v)∈E α(w, v) = π

2

∑(v,f)∈A f(v, f). Be-

cause a vertex v ∈ V has an outgoing edge to max. 4 adjacent faces with a lower boundof 1 an a demand of b(v) =

∑(v,f)∈A f(v, f) = 4 this implies that the angle-sum at v is

π2 b(v) = 2π.

According to that we have to show that the faces can exists by showing the correctnessformula (2) of Lemma 4.1 for each f ∈ F is true. This is trivial because the demand is:b(f) = −(2 deg(f)±4) and by a valid flow also b(f) =

∑(f,x)e∈A(f((f, x)e)−f((x, f)e)) =∑

(f ′,f)e∈AF(f((f ′, f)e)− f((f, f ′)e)) +

∑(v,f)∈V×F f(v, f). By the assumptions

b(f) =∑

(v,w)=e∈E(f)

(τ(v, w)− τ(w, v))−∑

(v,w)∈E(f)

α(v, w)

= −∑

(v,w)∈E(f)

(τ(w, v)− τ(v, w) + α(v, w))

which is one side of the formula. This finally implies that (2) of Lemma 4.1 is correct forthe induced representation.

Because the costs of a valid flow corresponds to the number of bends on edge segmentswith the described reduction that finally offers that for an orthogonal planar drawing

14

Page 15: Handout Presentation 7-02-13 Graph Drawing

-4-2

-14

213

2

3 32

(a)

-4 -2

-14

13

2

3 32

(b)

Figure 18: An illustration of two valid different flows of the min-cost-flow network forbend minimization. Only the face-to-face edges have costs of one; Flow (a) has costs of 3and corresponds to a drawing with 3 bends and (b) has costs 1 and corresponds to anoptimal orthogonal planar drawing with a single bend.

with fixed embedding the number of bends can be minimized by solving the minimumcost flow problem of the defined flow network. Figure 18 shows two different valid flowswith their corresponding orthogonal planar representation of the graph.

There exists some algorithms to solve a min-cost-flow problem. One algorithm especialfor this problem is presented in [1] but with a little modification on the demand function:for inner/outer faces f : b(f) := 4 ∓ deg(f) and for vertices v : b(v) = 4 − deg(v).This modification removes the lower bound on vertex-to-face edges in the dual graph soα(v, w) = f(v, h) + 1 where h is the next face in anticlockwise order at vertex v and edgev, w. Although the presented method is for orthogonal planar drawings of graphs with amaximum degree 4 there are also variants using this flow-problem method to optimizethe number of bends in a graph with a degree greater than 4 [4].

References

[1] Sabine Cornelsen and Andreas Karrenbauer. Accelerated bend minimization. InMarc J. van Kreveld and Bettina Speckmann, editors, Graph Drawing, volume 7034of Lecture Notes in Computer Science, pages 111–122. Springer, 2011.

[2] Ron Davidson and David Harel. Drawing graphs nicely using simulated annealing.ACM Trans. Graph., 15(4):301–331, October 1996.

[3] Peter Eades. A Heuristic for Graph Drawing. Congressus Numerantium, 42:149–160,1984.

[4] Ulrich Fößmeier and Michael Kaufmann. Drawing high degree graphs with low bendnumbers. In Franz-Josef Brandenburg, editor, Graph Drawing, Symposium on GraphDrawing, GD 95, Passau, Germany, September 20-22, 1995, Proceedings, volume1027 of Lecture Notes in Computer Science, pages 254–266. Springer, 1995.

[5] Carsten Gutwenger. Application of SPQR-trees in the planarization approach fordrawing graphs. PhD thesis, 2010.

[6] Carsten Gutwenger, Karsten Klein, and Petra Mutzel. Planarity testing and optimaledge insertion with embedding constraints. In Proceedings of the 14th interna-

15

Page 16: Handout Presentation 7-02-13 Graph Drawing

tional conference on Graph drawing, GD’06, pages 126–137, Berlin, Heidelberg, 2007.Springer-Verlag.

[7] John E. Hopcroft and Robert Endre Tarjan. Dividing a graph into triconnectedcomponents. SIAM J. Comput., 2(3):135–158, 1973.

[8] Roberto Tamassia. On embedding a graph in the grid with the minimum number ofbends. SIAM J. Comput., 16(3):421–444, 1987.

[9] Roberto Tamassia. Graph drawing. In J.R. Sack and J. Urrutia, editors, Handbookof Computational Geometry. Elsevier Science, 1999.

16