50
Flow and Upward Planarity Graph Drawing, chapter 6 by: Ami Hauptman Masha Igra

Flow and Upward Planarity

  • Upload
    dash

  • View
    53

  • Download
    0

Embed Size (px)

DESCRIPTION

Flow and Upward Planarity. Graph Drawing, chapter 6 by: Ami Hauptman Masha Igra. Introduction. Upward planar: inclusion in a Planar st -Graph Angles in Upward Drawing Upward Planarity Testing of Embedded Digraphs Optimal Upward Planarity Testing of Single-Source Embedded Digraphs. - PowerPoint PPT Presentation

Citation preview

Page 1: Flow and Upward Planarity

Flow and Upward Planarity

Graph Drawing, chapter 6 by:

Ami Hauptman Masha Igra

Page 2: Flow and Upward Planarity

IntroductionUpward planar: inclusion in a Planar st-

GraphAngles in Upward DrawingUpward Planarity Testing of Embedded

DigraphsOptimal Upward Planarity Testing of Single-

Source Embedded Digraphs

Page 3: Flow and Upward Planarity

IntroductionA digraph is upward planar if it admits a

planar and upward drawing.

• upward – edges are monotonically increasing in the vertical direction• planar – no two edges intersect

Page 4: Flow and Upward Planarity

IntroductionAn embedded graph described by circular order

of the neighbors of each vertex.

Page 5: Flow and Upward Planarity

Inclusion in a Planar st-GraphA planar st-graph is an st-graph that is

planar and embedded with vertices s and t on the boundary of the external face.

St-graph is an acyclic graph with a single source s and single sink t

S

t

Page 6: Flow and Upward Planarity

Theorem 6.1Let G be a digraph. The following statements are

equivalent:1. G is upward planar2. G admits an upward planar straight-line

drawing3. G is the spanning subgraph of a planar st-graph

Page 7: Flow and Upward Planarity

1(upward planar) 3(spanning subgraph of a planar st-

graph)

s,t respc. lowest and highest y coord.At sink v ≠ t draw new edge upwardAdd new edges (v, dest(e))Able to cancel all sinks, except tSpecial casesSimilar process cancels all sources, except sStatement shown.

Page 8: Flow and Upward Planarity

3 (G is spanning subgraph of a planar st-

graph G’) 2 (G admits an upward planar straight-line

drawing)

3 steps:1) Add edges to G′. Resulting

digraph G′′ is planar st-graph with all faces consisting of three edges

2) Construct an upward planar straight-line drawing of G′′

3) Remove edges that don’t belong to G from drawing of G′′

Page 9: Flow and Upward Planarity

Step 1: faces triangulation

f : a face of planar st-graph G’ (Lemma 4.1): r

Pf

origin(f)

dest(f)

lP

1v

2v

3v

4v

lP

Lemma 6.1: P = or , P = , k >= 4. Edge or can be added, such a resulting digraph is a planar st-graph

),...,(1 k

vv ),(11 k

vv ),(2 k

vvl

Pr

P

Lemma 6.2: and has at least 3 vertices. Edge can be added, such a resulting digraph is a planar st-graph

),(rl

vvl

Pr

P

lv

rv

Page 10: Flow and Upward Planarity

Step 2: Upward planar straight-line drawing

Lemma 6.4: Let G be a planar st-graph with all faces consisting of three edges. Given any upward planar straight-line drawing Δ for the external face of G, there exists an upward planar straight-line drawing of G with the external face drawn as Δ.

Proof: by induction on the number n of vertices of G.n = 3,holds for graphs with fewer than n vertices:v – not on external face,χ – undirected cycle of the neighbors of v

v

s

t

Case 1: χ – has a chord (u, w)

λ – undirected cycle (u, v, w)

G1 and G2 – planar st-graphsBy induction: Γ1 of G1, with external face Δ. Γ2 of G2, with external face λ

u

w

G1

G2

Page 11: Flow and Upward Planarity

Step 2: cont.Case 1: χ – has no chord

u – a predecessor of v, such that there is no directed path from u to any other predecessor of v (highest topological numbering).

*Contract edge (u,v) into vertex u:* The resulting G’ is a planar st-graph with n-1 vertices.* By induction: Γ’ of G’ with external face Δ.* Reinsert v: - every vertex properly visible from v,

- below its successors and above its predecessors

v

u u

Page 12: Flow and Upward Planarity

2 (G admits upward planar straight-line drawing) 3 (G is spanning subgraph of a planar st-graph)

3 (G is spanning subgraph of a planar st-graph)1 (G is upward planar):- Given a planar st-graph G’ including G- Construct a planar polyline drawing of G’ (Ch. 4) - Remove edges that do not belongs to G

Page 13: Flow and Upward Planarity

Planar n-vertex st-graph testing – O(n):- G has a single source s and a single sink t – O(n)

- G is planar – O(n) (ch. 3)- G is acyclic – O(n) (DFS)

Upward planarity testing algorithm – exponential-timeAdding all the possible subsets of edges and testing whether each of the resulting digraphs is a planar st-graph

Page 14: Flow and Upward Planarity

Target: polynomial time UP testing for embedded digraphsDrawing = points to Vs; curves to edgesEmbedding = eqv. class of Drawings (same

clockwise edges)Definitions

Bimodal vertex: cyclic edge sequence can be partitioned to incoming, outgoing (possibly empty)

Bimodal graph: all edges bimodalUpward planarity Bimodality (Lemma 6.5)Planar st-graphs are UP they are also bimodal

NOT true in other direction: e.g. simple 3-cycle

6.2 – Angles in Upward Drawings

Page 15: Flow and Upward Planarity

Angles of a Graph

Formed in embedding between 2 consecutive edges of same vertex straight-line drawing

Single edge angle = 2*PI

Page 16: Flow and Upward Planarity

Large and Small Angles

Only between pairs of incoming (or outgoing) edges

Intuition: Small < PI; Large > PIUsed in UP straight-line drawing

If p = vertex OR faceL(p) = number of Large angles of pS(p) = number of Small angles of p

Page 17: Flow and Upward Planarity

Example-Small and Large Angles

• Here edges are undirected; • “F” means a FLAT angle – between incoming AND outgoing edges (not needed)

Page 18: Flow and Upward Planarity

Angle Consistency Properties

The following holds for any UP straight-line drawing (for all fs, vs):

Follows from elementary geometryIntuition: external face has more large angles; Start from triangle (S=2,L=0) and add

points

Page 19: Flow and Upward Planarity

Angles Consistency - Example

Only Large angles coloredDifference between Small & Large is always 2External (h): more Large angles (due to Ss, Ts)

Page 20: Flow and Upward Planarity

Incoming OR Outgoing anglesA(f)= number of incoming (OR outgoing)

angles of face fSmall AND Large

For a given face: |Incoming| = |Outgoing|A is determined by Embedding; 2A(f) = L(f)+S(f)

Page 21: Flow and Upward Planarity

Lemma 6.6 RevisitedLemma 6.6 + simple algebra using 2A(f) =

L(f)+S(f)

WE GET:Lemma 6.7

As before, holds for any UP straight line drawing of G

Page 22: Flow and Upward Planarity

Vertices to faces - : v f (v): map each source\sink to one incident

faceAt least 2 faces possibleOnly non-internal vertices (only sources\sinks)

(f) = group of vertices assigned to f

Assignments

-1

Page 23: Flow and Upward Planarity

A(f)-1 next to each f; A(f)+1 next to h

Assignments - Example

Squares = facesA(f) -1 shown next to internal faces A(f)+1 shown next to external faces

Page 24: Flow and Upward Planarity

Consistent Assignments

is consistent if there exists a face h s.t.

h is the external faceRelative to Lemma 6.7:

6.7: |Large angels| on the left (here: |vs assigned|)

6.7: Also mentions angles of verticesAssigning v to f v will be Large in f

Hence this is (essentially) Lemma 6.7

Page 25: Flow and Upward Planarity

Consistency and Upward Planarity

Lemma 6.8:An embedded bimodal digraph is upward

planar only if it admits a consistent assignment of sources and sinks to facesA(f)-1 to all internal edges; A(f)+1 to external edgeThis is merely a reformulation of previous lemmas

Conditions in Lemmas 6.5-6.8 are also sufficientGIVEN embedded, bimodal digraph G with

consistent THEN G spans an UP st-graph (and hence G is UP)

Proved by correctness of Algorithm 6.1 below

Page 26: Flow and Upward Planarity

Algorithm 6.1

Mainly: apply 6.2 to each face; (except for h:) connect to s\t

Page 27: Flow and Upward Planarity

Switches

Source-switch (or sink-switch) of a face f = source (sink) of f

Switch of f = source OR sink of fA source (sink) in G

is a source(sink)-switch in all incident faces

Source in G =\= source in fAn internal vertex in G

Is a source or sink in all incident fs but twoE.g. central v is a switch in all fs but 2

lower ones

Page 28: Flow and Upward Planarity

Sequences σ of Switches

Using , assign to every source\sink:SL, tL = “Large” source\sink of fSs, ts = “Small” source\sink of f

σf = circular symbol sequence, obtained bytraversing f clockwiseGathering all SL, tL, Ss, ts symbols on the path

E.g. : σf = ts, SL, ts, SL, ts, Ss, ts…S\L not determined by drawing

Page 29: Flow and Upward Planarity

Algorithm 6.2 – Preliminaries

Canonical sub-sequences: “LSS” sequences of σf

We want to cancel sinks\sources (canceling Large angels)by adding edges in LSS subsequences

Two cases are possible:SL, ts, Ss add edge from Ss to SL

tL, Ss, ts add edge from tL to ts (cannot have 2 sinks\sources in a row)

New edge splits f (and hence splits σf )Ss SL cancels SL; tL ts cancels tL

Page 30: Flow and Upward Planarity

Algorithm 6.2 – Saturate Face

Page 31: Flow and Upward Planarity

Example 1 for Algorithm 6.2

f splits to f’ (next to split) and f’’ (containing LSS) σf splits to σf’ and σf’’Continue recursively with f’, σf’

Page 32: Flow and Upward Planarity

Splitting – Additional Examples

Page 33: Flow and Upward Planarity

Correctness Proof of Algorithm 6.1

Prove by showing:1) Edge insertions preserve planarity,

acyclicity and bimodality, as well as consistency of `

2) After all insertions, G’ has only one source and one sink on same f (which is h)

Page 34: Flow and Upward Planarity

Planarity, Acyclicity, Bimodality

Planarity – each edge is inserted inside a face, and hence no crossings

Acyclicity – assume a cycle exists; prove by contradiction to properties [omitted]

BimodalityAssume edge (z,x) is inserted between two

source-switches (for sinks – analogous)For x – (z,x) is the only incoming edge

bimodalFor z – outgoing edge (z,x) inserted between 2

outgoing bimodal

Page 35: Flow and Upward Planarity

Assignment Consistency Invariant

After inserting edge (z, x)-- `:1) All sources\sinks which were not canceled

are assigned by ’ to f’2) For all other sources\sinks = ` Hence ` is consistent

A A-1 so we need one less angle assigned

Page 36: Flow and Upward Planarity

Single Source and Sink Internal FacesAll are now with A(f)=1

(no vertex assigned)

All fs created contain exactly one source and one sink, both labeled S

Otherwise, there are still more canonical subsequencesA(f)+1 S symbols and A(f)-1 L “LSS” still exists and we can split

Page 37: Flow and Upward Planarity

Single Source and Sink [2] The External FaceA(h)+1 assigned sources\sinksStop when we have

k≥0 S symbols ; k+2 L symbols; no two S symbols in a row

Final sequence has following structure:σh = L1, σ1, L2, σ2; σ1=S,L,S,...,L,S;

σ2=S,L,S,...,L,SL symbols in one of σ1\2 referes to sources, the

other to sinks

Page 38: Flow and Upward Planarity

Final Step

Either connect L1 to highest and L2 to lowest OR add s,t

Page 39: Flow and Upward Planarity

Section Conclusion

Time complexity of Saturate Face is linear in f’s verticesSimple manipulations of σs

Algorithm 6.2 takes O(n) time

Proof: “only if” : from Lemmas 6.5-6.8“if” and O(n) : Lemma 6.9 and Theorem 6.1

Page 40: Flow and Upward Planarity

6.3 – Upward Planarity Testing How to construct consistent assignments?An algorithm for testing UP of an

embedded digraphNeed to test if a consistent assignment of

sources\sinks to faces exists given h

MAIN IDEA:Construct a biparitite flow network Bh

to represent assignments

Page 41: Flow and Upward Planarity

Bipartite Flow Network Bh

Nodes of Bh are sources, sinks and faces of G

Sources of Bh = Sources\sinks of GEach supplies 1 unit of flow

Sinks of Bh = Faces of GDemand = A(f)-1 for internal faces; A(f)+1 for h

Arcs of Bh(v,f) exists if v is a source\sink of G on face f

Page 42: Flow and Upward Planarity

Flow in BhAn assignment of values {0,1} to arcs of BhFor each source v of Bh :

Sum of values assigned to outgoing arcs of v supply of v

For each sink f of Bh :Sum of values assigned to incoming arcs of f

demand of fThe Value of the flow

= sum of values assigned to all arcs in Bh

Multi source\sink network:

Page 43: Flow and Upward Planarity

Example

a.

Page 44: Flow and Upward Planarity

Network Properties

G with n vertices O(n) vertices in BhG admits a consistent assignment Bh admits

a flow of value r with correct demandsr is number of sources & sinks in GDemands: A(f)+1 for External face; A(f)-1 for

internal

Page 45: Flow and Upward Planarity

Complexity of Basic UP Testing

1. Choose h O(n) possible choices

2. Construct Bh O(n) time [O(n) edges]

3. Test existence of flow |r| for Bh O(rn) time using r flow augmentations

4. If exists return #t ELSE choose next h Overall O(r*n ) = O(n )2 3

Page 46: Flow and Upward Planarity

Improvement - O(n ) timeAlgorithm 6.3 – Embedded-UP-TestConstruct a network B

Same as Bh but demands are [A(f) – 1] for ALL. Independent of h O(n)

Test whether B admits a flow of |r-2|. O(n-2)Try to increase demand by two for each face

test if flow of |r-2| can be augmented by two units Total: (r-1+r)*n = O(nr)

Return the set of all faces of G for which test was successful

2

Page 47: Flow and Upward Planarity

Optimal Upward Planarity Testing of Single-Source Embedded Digraphs

Face-sink graph F of G:

- Vertices of F: faces and vertices of G that are sink-switches

- Edges (f,v): v is a sink-switch of face f

F is a forest

Page 48: Flow and Upward Planarity

Thereom 6.6Let G be an embedded single-source digraph, and h a face of G.

Digraph G is upward planar, subject to h being the external face, if and only if all the following conditions are satisfied:

1. The source of G is on the boundary of face h.

2. The face-sink graph F of G is a forest.

3. One tree T of F has no internal vertices of G, while the remaining trees have exactly one internal vertex.

4. Face h is a vertex of tree T.

Page 49: Flow and Upward Planarity

Algorithm 6.4 Embedded-Single-Source-Upward-Planar-Test

O(n) time

Page 50: Flow and Upward Planarity

Thank you!