InfGraph Draw Automatic Graph Drawing Lecture 12 Planar

  • Slides: 44
Download presentation
Inf-Graph. Draw: Automatic Graph Drawing Lecture 12 Planar Orientations Reinhard von Hanxleden rvh@informatik. uni-kiel.

Inf-Graph. Draw: Automatic Graph Drawing Lecture 12 Planar Orientations Reinhard von Hanxleden rvh@informatik. uni-kiel. de Based on Chapters 4. 1 – 4. 6 of [Di Battista Book 99]. This lecture is based in part on material kindly provided by Tomer Heber and Matya Katz 1

5 -Minute Review 1. What is an SP digraph? 2. How much area may

5 -Minute Review 1. What is an SP digraph? 2. How much area may an upward, straight-line, embedding-preserving drawing of an SP digraph require? How about upward, straight-line, but not necessarily embedding-preserving drawing? 3. What approach did we use for the GFLP problem? 4. On planarity – what does Euler’s formula state? 5. What are the smallest non-planar graphs? How can we prove their non-planarity?

Outline & Goal • In this lesson we will deal with planar st-graphs (which

Outline & Goal • In this lesson we will deal with planar st-graphs (which will be explained later on). • We will review several algorithms for representing a st-planar graph. • We will also learn that by using those representations we can turn an st-planar graph to a more specific shape (such as a polyline). Goal of this lesson: Learn ways to represent a stgraph in a “useful” and “aesthetic” representation 3

Numbering of Digraphs Topological numbering of G: assignment of numbers to the vertices of

Numbering of Digraphs Topological numbering of G: assignment of numbers to the vertices of G, such that, for every edge (u, v) of G, the number assigned to v is greater then the one assigned to u. 5 2 3 4 2 1 4

Numbering of Digraphs The following statements are equivalent: • G is acyclic. • G

Numbering of Digraphs The following statements are equivalent: • G is acyclic. • G admits a topological numbering. • G admits a topological sorting. Thus: can do topological numbering (sorting) only on an acyclic graph. 5

Numbering of Digraphs Weighted topological numbering of G with nonnegative edge weights: Assignment of

Numbering of Digraphs Weighted topological numbering of G with nonnegative edge weights: Assignment of numbers to the vertices of G, such that, for every edge (u, v) of G, the number assigned to v is greater than or equal to the one assigned to u plus the weight of (u, v). 7 4 3 Numbering is optimal if 1 2 4 4 2 range of assigned numbers 2 is minimal. 1 1 0 0 0 6

Numbering of Digraphs Topological sorting: topological numbering of G, such that every vertex is

Numbering of Digraphs Topological sorting: topological numbering of G, such that every vertex is assigned a distinct integer between 1 and n. Topological sorting (if one exists) is unique if G has a directed path that visits every vertex. Note: if there are multiple such paths, then G is cyclic, hence no topological sorting. 6 5 3 4 2 1 7

ST-Graph ST-graph: acyclic digraph with a single source s and a single sink t

ST-Graph ST-graph: acyclic digraph with a single source s and a single sink t t has no outgoing edges t s s has no incoming edges Note: this st-graph is also an sp-graph 9

ST-Graph (2) For an st-graph G we have: • Given a topological numbering of

ST-Graph (2) For an st-graph G we have: • Given a topological numbering of G, every directed path of G visits with increasing numbers. • For every vertex v of G, there exists a simple directed path from s (source) to t (sink) that contains v. 10

Planar ST-Graph Planar st-graph: an st-graph that is planar and embedded, with vertices s

Planar ST-Graph Planar st-graph: an st-graph that is planar and embedded, with vertices s and t on the t boundary of the external face. Left/right boundary of external face: leftmost/rightmost path from s to t s [Di Battista Book 99] Note: this st-graph is not an sp-graph 11

Planar ST-Graph (2) We divide the external face into two representatives, associated with its

Planar ST-Graph (2) We divide the external face into two representatives, associated with its left/right boundary: Left external face s* Right external face t* s* t* [Di Battista Book 99] 12

Planar ST-Graph (3) • For each edge e = (u, v), define orig(e) =

Planar ST-Graph (3) • For each edge e = (u, v), define orig(e) = u and dest(e) = v • left(e) / right(e): face to the left / right of e orig(e) = u dest(e) = v left(e) = f 1 right(e) = f 2 v f 1 u e f 2 [Di Battista Book 99] 13

Lemma 4. 1 Each face f of G consists of two directed paths with

Lemma 4. 1 Each face f of G consists of two directed paths with common origin, called orig(f), and common destination, called dest(f). Proof: Let f be a face of G for which the lemma is not true. t dest(f) f w x u orig(f) • Must have edge (w, u) on boundary of f directed from dest(f) to orig(f) • There must be a path from u to t • There must be a path from s to w • Graph is planar, thus must exist node x where the passes intersect • w, u, x form a cycle! s 14

Lemma 4. 2 Incoming edges for each vertex v of G appear consecutively around

Lemma 4. 2 Incoming edges for each vertex v of G appear consecutively around v, and so do the outgoing edges. Proof: Lemma holds trivially for the vertices s and t. Let v be any other vertex, and suppose for a contradiction, that there are consecutive edges (v, w 0), (w 1, v), (v, w 2), (w 3, v). t w 0 v w 3 w 1 w 2 s x • Because every vertex in a st-graph is on simple path from s to t we add the following paths… • Because the graph is planar we add the vertex x to the graph. • We now have a cycle again! 15

Planar ST-Graph Properties (3) Since the incoming (outgoing) edges of each vertex of G

Planar ST-Graph Properties (3) Since the incoming (outgoing) edges of each vertex of G appear consecutively: Define left(v) as the face separating the incoming edges from the outgoing edges, in clockwise order, and right(v) as the other separating face left(v) v right(v) 16

Planar ST-Graph G* Define a digraph G* associated with planar stgraph G: • The

Planar ST-Graph G* Define a digraph G* associated with planar stgraph G: • The vertex set of G* is the set F of faces; recall that F has two representatives, s* and t*, of the external face • For every edge e ≠ (s, t) e of G, G* has an e* = (f, g) where f = left(e) and g = right(e). Note: G* is a planar st-graph as well left(e) right(e) 17

Lemma 4. 3 For any two faces f and g of a planar st-graph

Lemma 4. 3 For any two faces f and g of a planar st-graph G, exactly one of the following holds: • • G has a directed path from dest(f) to orig(g). G has a directed path from dest(g) to orig(f). G* has a directed path from f to g. G* has a directed path from g to f. 18

Proof of Lemma 4. 3 t P 1 P 2 P 4 P 3

Proof of Lemma 4. 3 t P 1 P 2 P 4 P 3 x dest(f) orig(g) • If directed path from dest(f) to orig(g) exists: lemma holds. If not: • Assume wlog that dest(f) is topologically before orig(g) • Define left-/rightmost path from v: path that always takes left-/rightmost edge • P 1/P 2: left-/rightmost path from dest(f) to t • P 3/P 4: left-/rightmost path from orig(g) to t • No path from dest(f) to orig(g) ⇒ P 2 must cross P 3 (or P 1 crosses P 4). Assume P 2 crosses P 3 (other case analogous), first at x • Lemma 4. 2 ⇒ every edge incident to vertex on P 2, from right side, is incoming (same for edges incident to P 3 from the left) • Construction of G* ⇒ must have directed path in G* from f to g ∎ 19

Lemma 4. 4 • An element of V ∪ E ∪ F is called

Lemma 4. 4 • An element of V ∪ E ∪ F is called an object of planar st-graph G. • For vertex v, define orig(v) = dest(v) = v • For face f, define left(f) = right(f) = f Reminder: we have already defined previously left(v), right(v), left(e), right(e), orig(e), dest(e), orig(f) and dest(f). 20

Lemma 4. 4 (2) For any two objects o 1 and o 2 of

Lemma 4. 4 (2) For any two objects o 1 and o 2 of a planar st-graph G, exactly one of the following holds: • • G has a directed path from dest(o 1) to orig(o 2). G has a directed path from dest(o 2) to orig(o 1). G* has a directed path from right(o 1) to left(o 2). G* has a directed path from right(o 2) to left(o 1). 21

Drawing ST-Graphs 1. 2. 3. 4. Tesselation representations Visibility representations Constrained visibility representations Polyline

Drawing ST-Graphs 1. 2. 3. 4. Tesselation representations Visibility representations Constrained visibility representations Polyline drawings 22

Drawing ST-Graphs 1. 2. 3. 4. Tesselation representations Visibility representations Constrained visibility representations Polyline

Drawing ST-Graphs 1. 2. 3. 4. Tesselation representations Visibility representations Constrained visibility representations Polyline drawings 23

Advertisement
Tiles • A tile (“Kachel”) is a rectangle with sides parallel to the coordinate

Tiles • A tile (“Kachel”) is a rectangle with sides parallel to the coordinate axes. • A tile can be unbounded or can degenerate to a segment or a point. • Two tiles are horizontally (vertically) adjacent if they share a portion of a vertical (horizontal) side. Tiles: Vertically adjacent: 24

Tessellation Representation A tessellation (“Kachelung”) representation Θ for planar st-graph G maps object o

Tessellation Representation A tessellation (“Kachelung”) representation Θ for planar st-graph G maps object o of G into a tile Θ(o) s. t. : • Interiors of tiles Θ(o 1) and Θ(o 2) are disjoint whenever o 1 != o 2. • Union of all tiles Θ(o), o ∈ V ∪ E ∪ F, is a rectangle. • Tiles Θ(o 1) and Θ(o 2) are horizontally adjacent iff o 1 = left(o 2) or o 1 = right(o 2) or o 2 = left(o 1) or o 2 = right(o 1). • Tiles Θ(o 1) and Θ(o 2) are vertically adjacent iff o 1 = orig(o 2) or o 1 = dest(o 2) or 25

Algorithm 4. 1: Tesselation Input: planar st-graph G Output: tesselation representation Θ of G

Algorithm 4. 1: Tesselation Input: planar st-graph G Output: tesselation representation Θ of G s. t. each vertex- and face-tile is a segment 1. Construct planar st-graph G* 2. Compute topological numbering Y of G 3. Compute topological numbering X of G* 4. X(left(e)) = 0 X(right(e)) = 1 Y(orig(e)) = 0 Y(dest(e)) = 2 X(left(f)) = 3 X(right(f)) = 3 Y(orig(f)) = 2 Y(dest(f)) = 4 X(left(v)) = 1 For each object o ∈ V ∪ E ∪ F, assign coordinates of tile Θ(o) x. L(o) = X(left(o)) x. R(o) = X(right(o)) y. B(o) = Y(orig(o)) y. T(o) = Y(dest(o)) 0 X(right(v)) = 3 Y(orig(v)) = 3 Y(dest(v)) = 3 4 3 1 v 4 f 3 3 2 2 2 1 e 1 0 2 1 3 1 4 0 0 1 2 3 4 27

Tessellation Representation (3) • Lemma 4. 4 implies that, for any tiles t 1

Tessellation Representation (3) • Lemma 4. 4 implies that, for any tiles t 1 and t 2, t 1 is either: above t 2, below t 2, left of t 2 or right of t 2. And only one of these directions is true. • Since each line of the algorithm is O(n), the total runtime of the algorithm is O(n). • The size of the Tessellation Representation can be modified by modifying the topological numbering (e. g. increasing the numbering to be 0. . 2. . 4 instead of 0. . 1. . 2 will make a Tessellation Representation twice bigger). 28

Drawing ST-Graphs 1. 2. 3. 4. Tesselation representations Visibility representations Constrained visibility representations Polyline

Drawing ST-Graphs 1. 2. 3. 4. Tesselation representations Visibility representations Constrained visibility representations Polyline drawings 29

Visibility Representation A visibility representation Γ of a planar st-graph G draws each vertex

Visibility Representation A visibility representation Γ of a planar st-graph G draws each vertex v as horizontal segment, called vertex segment Γ(v), and each edge (u, v) as vertical segment, called edge segment Γ(u, v) s. t. : 1. Vertex segments do not overlap. 2. Edge segments do not overlap. 3. Edge-segment Γ(u, v) has its bottom end point on Γ(u), its top end-point on Γ(v), and does not intersect any other vertex segment. 30

Algorithm 4. 2: Visibility Input: planar st-graph G with n vertices Output: visibility representation

Algorithm 4. 2: Visibility Input: planar st-graph G with n vertices Output: visibility representation Γ of G with integer coordinates and are O(n 2) 1. Construct planar st-graph G* 2. Assign unit weights to the edges of G and compute an optimal weighted topological numbering Y of G 3. Assign unit weights to the edges of G* and compute an optimal weighted topological numbering X of G* 31

4. For each vertex v, draw the vertex-segment Γ(v) at y-coordinate Y(v) and between

4. For each vertex v, draw the vertex-segment Γ(v) at y-coordinate Y(v) and between x-coordinates X(left(v)) and X(right(v)) – 1: for each vertex v do draw Γ(v) as horizontal segment with y(Γ(v)) = Y(v) x. L(Γ(v)) = X(left(v)) x. R(Γ(v)) = X(right(v)) – 1 endfor 4 3 1 4 3 0 2 2 2 1 3 0 3 2 1 1 4 1 0 0 1 2 3 4 32

5. For each edge e, draw the edge-segment Γ(e) at x-coordinate X(left(e)) and between

5. For each edge e, draw the edge-segment Γ(e) at x-coordinate X(left(e)) and between y-coordinates Y(orig(e)) and Y(dest(e)) : for each edge e do draw Γ(e) as vertical segment with x(Γ(e)) = X(left(e)) y. B(Γ(e)) = Y(orig(e)) y. T(Γ(e)) = Y(dest(e)) endfor 4 3 1 4 3 0 2 2 2 1 3 0 3 2 1 1 4 1 0 0 1 2 3 4 33

Visibility Representation Correctness of the algorithm follows from Lemma 4. 4 and the construction

Visibility Representation Correctness of the algorithm follows from Lemma 4. 4 and the construction of the algorithm: • Any two vertex segments are separated by a horizontal or vertical strip of at least unit width (Condition 1: vertex segments do not overlap). • Any two edge segments on opposite sides of a face are separated by a vertical strip of at least a unit width (Condition 2: edge segments do not overlap). • Each edge segment (u, v) has its bottom point intersecting with u vertex segment, and his upper point intersecting with v vertex segment (Condition 3: edge segments connect vertex segments). The runtime of the algorithm is O(n) since each step is O(n). 34

Drawing ST-Graphs 1. 2. 3. 4. Tesselation representations Visibility representations Constrained visibility representations Polyline

Drawing ST-Graphs 1. 2. 3. 4. Tesselation representations Visibility representations Constrained visibility representations Polyline drawings 35

Constrained Visibility Representation Let G be a planar st-graph with n vertices. Two paths

Constrained Visibility Representation Let G be a planar st-graph with n vertices. Two paths of π1 and π2 of G are said to be nonintersecting if they • are edge disjoint and • do not cross at common vertices π1 Note: vertex disjointness is a sufficient, but not necessary condition for this π1 π1 π2 π3 π3 36

Constrained Visibility Representation Given a collection ∏ of nonintersecting paths of G, we consider

Constrained Visibility Representation Given a collection ∏ of nonintersecting paths of G, we consider the problem of constructing a visibility representation Γ of G such that for every path π in ∏ we have the following constraint: For any two edges e’ and e’’ of π, the edge segments Γ(e’) and Γ(e’’) have the same x-coordinate. Note: We assume that ∏ covers all the edges in G (Any edge not originally in ∏ can be added as path in itself). 37

Algorithm 4. 3: Constrained Visibility Input: planar st-graph G with n vertices; set Π

Algorithm 4. 3: Constrained Visibility Input: planar st-graph G with n vertices; set Π of nonintersecting paths covering edges of G Output: constrained visibility representation Γ of G with integer coordinates and area O(n 2) 1. Construct graph GΠ with vertex set F ∪ Π and edge set { (f, Π) | f = left(e) for some edge e of path Π } ∪ { (Π, g) | g = right(e) for some edge e of path Π } 2. Assign unit weights to the edges of G and compute an optimal weighted topological numbering Y of G, such that Y(s) = 0 3. Assign half-unit weights to the edges of GΠ and compute an optimal weighted topological numbering X of GΠ, such that X(s*) = -1/2 38

1. Construct graph GΠ with vertex set F ∪ Π and edge set {

1. Construct graph GΠ with vertex set F ∪ Π and edge set { (f, Π) | f = left(e) for some edge e of path Π } ∪ { (Π, g) | g = right(e) for some edge e of path Π } 2. Assign unit weights to the edges of G and compute an optimal weighted topological numbering Y of G, such that Y(s) = 0 3. Assign half-unit weights to the edges of GΠ and compute an optimal weighted topological numbering X of GΠ, such that X(s*) = -1/2 ∏={π1, π2, π3, π4, π5, π6, π7, π8} 4 π7 π8 f 6 π1 f 1 π4 0. 5 2 π2 f 7 π1 π4 f 2 0. 5 π5 1 G 2 f 7 π2 f 3 0 3 2 f 4 f 1 π3 π6 1. 5 1 -0. 5 f 3 π5 0 2. 5 f 6 π6 3 1 f 2 π70 f 5 f 4 2 π8 G* 1 3. 5 2. 5 3 π3 39

4. for each path π in Π do for each edge e in path

4. for each path π in Π do for each edge e in path π do draw Γ(e) as vertical segment with x(Γ(e)) = X(π) y. B(Γ(e)) = Y(orig(e)) y. T(Γ(e)) = Y(dest(e)) endfor π8 4 π7 f 6 π1 f 2 π4 1 0 0 f 7 -0. 5 π1 f 5 π3 π4 f 2 2 f 7 π2 0. 5 π5 1 G π6 f 3 0 G* 3 π8 2 f 4 f 1 2 3 2. 5 1 1 Constrained visibility representation Γ of G f 3 π5 0 2 π2 1 2 f 6 π6 3 3 0. 5 f 4 2 π70 4 1 3. 5 2. 5 3 π3 40

5. for each vertex v do draw Γ(v) as horizontal segment with y(Γ(v)) =

5. for each vertex v do draw Γ(v) as horizontal segment with y(Γ(v)) = Y(v) x. L(Γ(v)) = minv∈π X(π) x. R(Γ(v)) = maxv∈π X(π) endfor 4 3 2 1 0 0 1 2 3 Constrained visibility representation Γ of G π8 4 π7 f 6 π1 f 1 π6 f 4 2 π4 f 7 0. 5 f 6 -0. 5 f 5 π1 π3 π4 f 2 0. 5 π5 1 G f 7 π2 f 3 0 2 2 f 4 f 1 π8 π6 1. 5 1 3 2. 5 f 3 π5 0 2 π2 1 f 2 Total Runtime O(n) f 5 3 π70 G* 1 3. 5 2. 5 3 π3 41

Drawing ST-Graphs Will discuss the following: 1. Tesselation representations 2. Visibility representations 3. Constrained

Drawing ST-Graphs Will discuss the following: 1. Tesselation representations 2. Visibility representations 3. Constrained visibility representations 4. Polyline drawings 42

Polyline Drawing • We can construct a planar upward polyline drawing of a planar

Polyline Drawing • We can construct a planar upward polyline drawing of a planar st-graph G using its visibility representation. • We draw each vertex in an arbitrary point inside its vertex segment. • We draw each edge (u, v) of G as a three segment polygonal chain. 43

Algorithm 4. 4: Polyline Input: planar st-graph G Output: planar upward polyline grid drawing

Algorithm 4. 4: Polyline Input: planar st-graph G Output: planar upward polyline grid drawing of G 1. Construct visibility representation Γ of G with integer coordinates 2. for each vertex v do replace the vertex segment Γ(v) with an arbitrary point P(v) = (x(v), y(v)) on Γ(v) endfor 3. for each edge (u, v) do if y(v) – y(u) = 1 then // short edge replace the edge segment Γ(u, v) with the segment with end points P(u) and P(v) else // long edge replace the edge segment Γ(u, v) with the polygonal line from P(u) and P(v) through (x(Γ(u, v)), y(u)+1) and (x(Γ(u, v)), y(v)– 1) endfor 4 3 2 2 1 1 0 44

Polyline Drawing • Since every step in the algorithm is O(n), the total complexity

Polyline Drawing • Since every step in the algorithm is O(n), the total complexity runtime is O(n). • We can reduce the number of “bends” if we put each place vertex on intersections between an edge segment and vertex segment. 45

Summary & Outlook • ST graphs are acyclic, single source s, single sink t

Summary & Outlook • ST graphs are acyclic, single source s, single sink t • Planar st graphs: planar, embedded, s and t on boundary of external face • Discussed how to produce tesselation/(constrained) visibility/polyline representation of st graphs, based on topological numberings in x and y direction • Can extend this to arbitrary planar graphs by picking some s and t • This in turn can be extended to arbitrary graphs by a planarization step that (temporarily) removes a (preferrably minimal) set of edges 46