introduction to graph drawing

37
INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G. 1998 Graph Drawing: Algorithms for the Visualization of Graphs . 1st. Prentice Hall PTR.

Upload: jamuna

Post on 06-Jan-2016

47 views

Category:

Documents


0 download

DESCRIPTION

Introduction to Graph drawing. Fall 2010 Battista, G. D., Eades , P., Tamassia , R., and Tollis , I. G. 1998 Graph Drawing: Algorithms for the Visualization of Graphs . 1st. Prentice Hall PTR. Data flow analysis. Scheduling. Electrical networks. Database logic algorithm. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to  Graph drawing

INTRODUCTION TO GRAPH DRAWING

Fall 2010

Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G. 1998 Graph Drawing: Algorithms for the Visualization of Graphs. 1st. Prentice Hall PTR.

Page 2: Introduction to  Graph drawing

DIVIDE AND CONQUERSERIES-PARALLEL DIGRAPHS

Scheduling

Electrical networks

Data flow analysis

Database logic algorithm

Page 3: Introduction to  Graph drawing

SERIES-PARALLEL DIGRAPHS

Directed graph with a source and sink nodes or poles.

source

sink

Page 4: Introduction to  Graph drawing

THE RECURSIVE DEFINITION OF S-P DIGRAPH

An edge joining two vertices is a s-p digraph. (a)

Let G’ and G” be two s-p digraphs these two compositions of them also are s-p digraphs: The series composition of G’ and G” is

the digraph obtained identifying the sink of G’ with the source of G”. (b)

The parallel composition of G’ and G” is the digraph obtained by identifying the source of G’ with the source of G” and the sink of G’ with the sink of G”. (c)

Page 5: Introduction to  Graph drawing

SERIES COMPOSITION OF DIGRAPHS

Identifying the sink of one and the source of the other as one vertex

source

source

source

sink sink

sink

Page 6: Introduction to  Graph drawing

PARALLEL COMPOSITION OF DIGRAPHS

Identifying as one vertex both their sources Identifying as one vertex both their sinks

source

sink

source

source

sink sink

Page 7: Introduction to  Graph drawing

DECOMPOSITION TREES

A series-parallel digraphs is associated with a binary tree named decomposition tree or parse tree

There are three different kinds of nodes in this tree: S-nodes, P-nodes and Q-nodes.

Page 8: Introduction to  Graph drawing

THE RECURSIVE DEFINITION OF DECOMPOSITION TREES

G is a single edge so T is a single Q-node

Q

Page 9: Introduction to  Graph drawing

DECOMPOSITION TREES

If G is a parallel composition of s-p digraphs: G1 and G2 , and T1 and T2 are their decomposition trees respectively, then T the decomposition tree of G has a root which is a P-node and two subtrees T1 and T2

P

T1 T2

Page 10: Introduction to  Graph drawing

DECOMPOSITION TREES

If G is a series composition of s-p digraph:G1 and G2 , the sink of G1 is identified with the source of G2 .And T1 and T2 are their decomposition trees respectively, then T the decomposition tree of G has a root which is a S-node and two subtrees T1 and T2

S

T1 T2

Page 11: Introduction to  Graph drawing

DECOMPOSITION TREES

The leaves of T are Q-nodes The internal nodes are either S-nodes or P-

nodes. If a node has the same type as its parent

it will be the right child T is unique for G If G has n nodes then T has O(n) leaves and

O(n) nodes. (graph G is simple) T can be created in O(n) time so will be

assumed to be part of the input

Page 12: Introduction to  Graph drawing

P

T1 T2S

P

T1

S

Q

Q Q

P

T1

S

Q

T2

Page 13: Introduction to  Graph drawing

P

PS

SQ

Q Q

S

SQ

Q Q

S

SQ

P

SQ

Q Q

S

SP

Q QSQ

Q Q

The leaves of T are Q-

nodes

The internal nodes are

either S-nodes or P-

nodes.

If a node has the same

type as its parent

it will be the right child

T is unique for G

Page 14: Introduction to  Graph drawing

COMPONENTS

Let C be a maximal path of same node type on T

Let u1 … uk children of C not on C Component is the part of G associated with a

subsequence ui … uj where 1 ≤ i ≤ j ≤ k Component is closed when C is of S-nodes Otherwise it is open

Page 15: Introduction to  Graph drawing

CLOSED COMPONENTP

PS

SQ

Q Q

S

SQ

Q Q

S

SQ

P

SQ

Q Q

S

SP

Q QSQ

Q Q

Page 16: Introduction to  Graph drawing

E. Di Giacomo, Drawing series-parallel graphs on restricted integer 3D grids, in Proc. 11th International Symp. on Graph Drawing (GD ’03), vol. 2912 of Lecture Notes in Comput. Sci., Springer, 2004, pp. 238–246.

Page 17: Introduction to  Graph drawing

OPEN COMPONENT

Page 18: Introduction to  Graph drawing

NOT A CLOSED COMPONENT

Page 19: Introduction to  Graph drawing

LOOKING FOR A DRAWING FOR S-P DIGRAPH

It has been proved that : there exist embedded s-p digraphs that any of their upward straight-line drawing that preserves embedding, requires exponential area.

[ P.Bertolizza, R.F. Cohen, G.Di Battista, R. Tamassia and I.G. Tollis: “How to Draw a Series-Parallel Digraph”, Internat J.Comput. Geom. Appl., 4, 385-402, 1994. ]

[ A. Garg and R. Tamassia,:” Efficient Computation of Planar Straight-Line Upward Drawing”, In GD 93, (Proc. ALCOM Workshop on Graph Drawing.) 1993. ]

To have a drawing with polynomial area it is necessary to change the given embedding.

Page 20: Introduction to  Graph drawing

RIGHT-PUSHED EMBEDDING

The edge (u,v) in G is transitive if there is

another path from u to v other than (u,v).

Drawing transitive edge (u, v) on the right of

all components with u and v poles

Page 21: Introduction to  Graph drawing

Δ-SP-DRAW

Drawing inside a bounding

triangle Δ(Γ) which is isosceles

and right-angled.

Series composition: one above

the other

Parallel – one to the right of the

other

base

top side

bottom side

G1

G2

G1

G2

Page 22: Introduction to  Graph drawing
Page 23: Introduction to  Graph drawing

Δ-SP-DRAW – BASE

If G is a single edge Draw it as a vertical edge Bounding triangle Δ(Γ)

G

t

s

Page 24: Introduction to  Graph drawing

Δ-SP-DRAW – SERIES

If G is a series composition of G1 and G2 Recursively draw Γ1 and Γ2 Translate Γ2 so G2’s sink is on G1’s source Extend bounding triangle Δ(Γ) accordingly

G1

G2

Page 25: Introduction to  Graph drawing

PRESCRIBED-REGION

(v, t) and (s, u) are rightmost

edges on G1

λv and λu are rays parallel

to G1’s bounding triangle

G2 will be translated to

anywhere on the right of

λv, λu and k.

G1

G2v

u

k

t

s

λv

λu

Page 26: Introduction to  Graph drawing

If G is a parallel composition of G1 and G2 Recursively draw Γ1 and Γ2 Translate Γ2 to the “prescribed-region” of

G2(right of the dashes)

Extend bounding triangle Δ(Γ)accordingly

Move sources and sinks toupper and lower corners of Δ(Γ)

Δ-SP-DRAW – PARALLEL

G1

G2

Page 27: Introduction to  Graph drawing

t

s

12

3

P

S S

Q QSQ

Q Q

s’

t’

3

s”

t”

1

2

Page 28: Introduction to  Graph drawing

MOVING SOURCE AND SINK

s’

t’

3

s”

t”

1

2

t

s

12

3

Page 29: Introduction to  Graph drawing

INVARIANTS

The drawing is contained inside the right angled triangle.

The source and sink are placed at the bottom and top corner of Δ(Γ) respectively.

For any vertex u adjacent to the source s of G, the wedge formed at u by rays with slopes -/2 and -/4 does not contain any vertex of G except s.

For any vertex v adjacent to the sink t of G, the wedge formed at v by rays with slopes /2 and /4 does not contain any vertex of G except t.

t

s

u

Page 30: Introduction to  Graph drawing

LEMMA 3.3

Let u and v be neighbors of the sourceso (s, u) is left of (s, v)

Let λu and λv be rays of slope - /4from u and v

If invariant 3 holdsthen λu is below λv

s

u v

λu

λv

Page 31: Introduction to  Graph drawing

LEMMA 3.3 – OUTCOME

If G2 is placed to the right of G1 and above λuwhere (s, u) is the rightmost edge of s on G1

Then no vertex of G2 is in the wedge limited by the –/4 ray from the neighbors of s

Hence if invariant 3 is held onG1 and G2 it is also held on G

Symmetrically invariant 4 can be proved

s

u

Page 32: Introduction to  Graph drawing

THEREFORE

Proving Invariants 3 and 4 guarantee thats and t can be moved as described in the algorithm without creating crossings.

Invariant 2 states that left cornerof Δ(Γ) is always empty,so G2’s left corner can beon the base of G1.

Page 33: Introduction to  Graph drawing

AREA OF THE TRIANGLE

So the base of resulting triangle is equals the sum of bases of both triangles.

For a graph with n vertices the length of the base is 2n.

So the area needed is O(n2)

Page 34: Introduction to  Graph drawing

CALCULATING DISTANCES

We’ll describe Γ by:b = length of the baseb’ = vertical distance to λub” = vertical distance to λv v

u

κ

t

s

λv

λu

b’

b’’

b

Page 35: Introduction to  Graph drawing

PARALLEL DISTANCES

To describe parallel combinations we’ll use:Δx = horizontal distance from

Δ(Γ1) to Δ(Γ2)Δy = vertical distance from

bottom ray of Δ(Γ1) toleft corner of Δ(Γ2) Δx

Δy

Page 36: Introduction to  Graph drawing

Δ-SP-LABELinput : decomposition tree T of Goutput : labeling b, b’, b’’ for each subtree of Tif root = Q-node then

b(T) = b’(T) = b’’(T) = 2else

Δ-SP-label of T1 and T2 (the subtrees)if root = S-node then

b(T) = b(T1) + b(T2)b’(T) = b(T1)b’’(T) = b(T2)

else root = P-node thenb(T) = b(T1) + b(T2)+2Δxif T2 is Q-node (transitive edge) thenb’(T) = b’’(T) = b(T)elseb’’(T) = b(T1) + 2Δx – Δy + b’’(T2)b’(T) = b’(T2) + Δy

Page 37: Introduction to  Graph drawing

Δ-SP-LABEL

Δx can be 0 Δy can be b’(T1) The area needed is O(n2) The algorithm runs in O(n)

and needs O(n) space

end of Series-Parallel Digraphs