flow methods: upward planarity algorithms for graph

50
Torsten Ueckerdt 1 Torsten Ueckerdt Algorithms for Graph Visualization INSTITUT F ¨ UR THEORETISCHE INFORMATIK · FAKULT ¨ AT F ¨ UR INFORMATIK Flow Methods: Upward Planarity 11.12.2019

Upload: others

Post on 23-Dec-2021

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt1

Torsten Ueckerdt

Algorithms for Graph Visualization

INSTITUT FUR THEORETISCHE INFORMATIK · FAKULTAT FUR INFORMATIK

Flow Methods: Upward Planarity

11.12.2019

Page 2: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt2 - 1

Upward Planarity

Def: A directed acyclic graph D = (V,A) is called upwardplanar, when D admits a drawing (vertices points, edgessimple curves), which is planar and each edge is amonotone curve increasing in y-direction.

Page 3: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt2 - 2

Upward Planarity

Def: A directed acyclic graph D = (V,A) is called upwardplanar, when D admits a drawing (vertices points, edgessimple curves), which is planar and each edge is amonotone curve increasing in y-direction.

Example:

Page 4: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt2 - 3

Upward Planarity

Def: A directed acyclic graph D = (V,A) is called upwardplanar, when D admits a drawing (vertices points, edgessimple curves), which is planar and each edge is amonotone curve increasing in y-direction.

Example:

planar!

upward planar? – NO!

Page 5: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt3 - 1

Complexity

Thm 1:For a directed acyclic graph it is NP-hard to decidewhether it is upward planar.

[Garg, Tamassia GD 1995]

Page 6: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt3 - 2

Complexity

Thm 1:For a directed acyclic graph it is NP-hard to decidewhether it is upward planar.

[Garg, Tamassia GD 1995]

Thm 2:For a combinatorially embedded planar directedgraph it can be tested in O(n2) time whether it isupward planar. [Bertolazzi et al.Algorithmica, 1994]

Page 7: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt3 - 3

Complexity

Thm 1:For a directed acyclic graph it is NP-hard to decidewhether it is upward planar.

[Garg, Tamassia GD 1995]

Thm 2:For a combinatorially embedded planar directedgraph it can be tested in O(n2) time whether it isupward planar. [Bertolazzi et al.Algorithmica, 1994]

Corol: For a triconnected planar directed graph it can betested in O(n2) time whether it is upward planar.

[Bertolazzi et al.Algorithmica, 1994]

Page 8: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt3 - 4

Complexity

Thm 1:For a directed acyclic graph it is NP-hard to decidewhether it is upward planar.

[Garg, Tamassia GD 1995]

Thm 2:For a combinatorially embedded planar directedgraph it can be tested in O(n2) time whether it isupward planar. [Bertolazzi et al.Algorithmica, 1994]

Corol: For a triconnected planar directed graph it can betested in O(n2) time whether it is upward planar.

[Bertolazzi et al.Algorithmica, 1994]

Thm 3:For a single-source acyclic digraph it can be testedwhether it is upward planar in O(n) time.

[Hutton, Lubiw, SIAM J.Comp.,1996]

Page 9: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt3 - 5

Complexity

Thm 1:For a directed acyclic graph it is NP-hard to decidewhether it is upward planar.

[Garg, Tamassia GD 1995]

Thm 2:For a combinatorially embedded planar directedgraph it can be tested in O(n2) time whether it isupward planar. [Bertolazzi et al.Algorithmica, 1994]

Corol: For a triconnected planar directed graph it can betested in O(n2) time whether it is upward planar.

[Bertolazzi et al.Algorithmica, 1994]

Thm 3:For a single-source acyclic digraph it can be testedwhether it is upward planar in O(n) time.

[Hutton, Lubiw, SIAM J.Comp.,1996]

NEXT

Page 10: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt4 - 1

Characterization

Thm 4:For a directed graph D = (V,A) the followingstatements are equivalent:(1) D is upward planar(2) D admits an upward planar straight-line drawing(3) D is the spanning subgraph of a planar st-digraph

[Di Battista, Tamassia TCS 1988]

Page 11: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt4 - 2

Characterization

Thm 4:For a directed graph D = (V,A) the followingstatements are equivalent:(1) D is upward planar(2) D admits an upward planar straight-line drawing(3) D is the spanning subgraph of a planar st-digraph

st-digraph: (i) single source s and sink t, (ii) edge (s, t) ∈ E

[Di Battista, Tamassia TCS 1988]

Page 12: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt4 - 3

Characterization

Thm 4:For a directed graph D = (V,A) the followingstatements are equivalent:(1) D is upward planar(2) D admits an upward planar straight-line drawing(3) D is the spanning subgraph of a planar st-digraph

st-digraph: (i) single source s and sink t, (ii) edge (s, t) ∈ E

Proof: • (2) ⇒ (1) obvious• (1) ⇔ (3) simple augmentation of a layout (blackboard)• (3) ⇒ (2) triangulation and construction of straight-line

drawing (blackboard)

[Di Battista, Tamassia TCS 1988]

Page 13: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt4 - 4

Characterization

Thm 4:For a directed graph D = (V,A) the followingstatements are equivalent:(1) D is upward planar(2) D admits an upward planar straight-line drawing(3) D is the spanning subgraph of a planar st-digraph

st-digraph: (i) single source s and sink t, (ii) edge (s, t) ∈ E

Proof: • (2) ⇒ (1) obvious• (1) ⇔ (3) simple augmentation of a layout (blackboard)• (3) ⇒ (2) triangulation and construction of straight-line

drawing (blackboard)

[Di Battista, Tamassia TCS 1988]

Page 14: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt4 - 5

Characterization

Thm 4:For a directed graph D = (V,A) the followingstatements are equivalent:(1) D is upward planar(2) D admits an upward planar straight-line drawing(3) D is the spanning subgraph of a planar st-digraph

st-digraph: (i) single source s and sink t, (ii) edge (s, t) ∈ E

Proof: • (2) ⇒ (1) obvious• (1) ⇔ (3) simple augmentation of a layout (blackboard)• (3) ⇒ (2) triangulation and construction of straight-line

drawing (blackboard)

[Di Battista, Tamassia TCS 1988]

Pair, think and share:

3 minHow to do the augmentation in case of adisconnected graph?

Page 15: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt4 - 6

Characterization

Thm 4:For a directed graph D = (V,A) the followingstatements are equivalent:(1) D is upward planar(2) D admits an upward planar straight-line drawing(3) D is the spanning subgraph of a planar st-digraph

st-digraph: (i) single source s and sink t, (ii) edge (s, t) ∈ E

Proof: • (2) ⇒ (1) obvious• (1) ⇔ (3) simple augmentation of a layout (blackboard)• (3) ⇒ (2) triangulation and construction of straight-line

drawing (blackboard)

[Di Battista, Tamassia TCS 1988]

Page 16: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt4 - 7

Characterization

Thm 4:For a directed graph D = (V,A) the followingstatements are equivalent:(1) D is upward planar(2) D admits an upward planar straight-line drawing(3) D is the spanning subgraph of a planar st-digraph

st-digraph: (i) single source s and sink t, (ii) edge (s, t) ∈ E

Proof: • (2) ⇒ (1) obvious• (1) ⇔ (3) simple augmentation of a layout (blackboard)• (3) ⇒ (2) triangulation and construction of straight-line

drawing (blackboard)

[Di Battista, Tamassia TCS 1988]

Pair, think and share:

5 minIs the area produced by the algorithm describedin the proof of (3) ⇒ (2) polynomial?

Page 17: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt4 - 8

Characterization

Thm 4:For a directed graph D = (V,A) the followingstatements are equivalent:(1) D is upward planar(2) D admits an upward planar straight-line drawing(3) D is the spanning subgraph of a planar st-digraph

st-digraph: (i) single source s and sink t, (ii) edge (s, t) ∈ E

Proof: • (2) ⇒ (1) obvious• (1) ⇔ (3) simple augmentation of a layout (blackboard)• (3) ⇒ (2) triangulation and construction of straight-line

drawing (blackboard)

[Di Battista, Tamassia TCS 1988]

• Step (3) ⇒ (2) implies an O(n) algorithm to construct a planarstraight-line drawing of an st-digraph.

Page 18: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt5 - 1

Fixed Outer Face: Angles

Problem:Consider a directed acyclic graph D = (V,A) withembedding F , f0 . Test whether D,F , f0 is upwardplanar and construct corresponding drawing.

Page 19: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt5 - 2

Fixed Outer Face: Angles

Problem:Consider a directed acyclic graph D = (V,A) withembedding F , f0 . Test whether D,F , f0 is upwardplanar and construct corresponding drawing.

Embedding is bimodalif for each node:

incomming

outgoing

Page 20: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt6 - 1

Fixed Outer Face: Observations

• Bimodality is necessary but not sufficient

Page 21: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt6 - 2

Fixed Outer Face: Observations

• Bimodality is necessary but not sufficient• measure angles between two incoming or two outgoingedges Angle α is large when α > π, small otherwise

L(v) := # large angles at node vL(f) := # large angles in face fS(v) resp. S(f): # small angles

Page 22: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt6 - 3

Fixed Outer Face: Observations

• Bimodality is necessary but not sufficient• measure angles between two incoming or two outgoingedges Angle α is large when α > π, small otherwise

L(v) := # large angles at node vL(f) := # large angles in face fS(v) resp. S(f): # small angles

Lemma 1: In any upward layout of D holds:

(1) ∀v ∈ V : L(v) =

{0 v not source/sink

1 v source/sink

(2) ∀f ∈ F : L(f)− S(f) =

{−2 f 6= f0

2 f = f0

Page 23: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt6 - 4

Fixed Outer Face: Observations

• Bimodality is necessary but not sufficient• measure angles between two incoming or two outgoingedges Angle α is large when α > π, small otherwise

L(v) := # large angles at node vL(f) := # large angles in face fS(v) resp. S(f): # small angles

Lemma 1: In any upward layout of D holds:

(1) ∀v ∈ V : L(v) =

{0 v not source/sink

1 v source/sink

(2) ∀f ∈ F : L(f)− S(f) =

{−2 f 6= f0

2 f = f0

Pair, think and share:5 minThink about property (2). Why does it hold?

Page 24: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt6 - 5

Fixed Outer Face: Observations

Lemma 1: In any upward layout of D holds:

(1) ∀v ∈ V : L(v) =

{0 v not source/sink

1 v source/sink

(2) ∀f ∈ F : L(f)− S(f) =

{−2 f 6= f0

2 f = f0

Page 25: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt7 - 1

Fixed Outer Face: Observations

• A(f) := # sources in face f (equal to the number of sinks)

It holds that: L(f) + S(f) = 2A(f) for all faces.

• in any upward planar layout of D holds:

∀f ∈ F : L(f) =

{A(f)− 1 f 6= f0

A(f) + 1 f = f0

Page 26: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt7 - 2

Fixed Outer Face: Observations

• A(f) := # sources in face f (equal to the number of sinks)

It holds that: L(f) + S(f) = 2A(f) for all faces.

• in any upward planar layout of D holds:

∀f ∈ F : L(f) =

{A(f)− 1 f 6= f0

A(f) + 1 f = f0

• Define assignment Φ : S ∪ T → F(S set of sources, T sinks), whereΦ : v 7→ incident face, where v is forms large angle

• Φ is called consistent, if: |Φ−1(f)| =

{A(f)− 1 f 6= f0

A(f) + 1 f = f0

Page 27: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt8 - 1

Example: Vertex-Face Assignment

f1

f2

f3

f4

f5

f6

f7

f8

f9

f0

Page 28: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt8 - 2

Example: Vertex-Face Assignment

L(f1) = 2

A(f1) = 3

L(f4) = 1

A(f4) = 2

A(f5) = 2

L(f5) = 1

L(f2) = 0

A(f2) = 1

L(f0) = 4

A(f0) = 3

L(f7) = 1

A(f7) = 2

L(f3) = 0

A(f3) = 1

L(f6) = 0

A(f6) = 1

L(f8) = 0

A(f8) = 1

L(f9) = 0

A(f9) = 1

f1

f2

f3

f4

f5

f6

f7

f8

f9

f0

Page 29: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt8 - 3

Example: Vertex-Face Assignment

L(f1) = 2

A(f1) = 3

L(f4) = 1

A(f4) = 2

A(f5) = 2

L(f5) = 1

L(f2) = 0

A(f2) = 1

L(f0) = 4

A(f0) = 3

L(f7) = 1

A(f7) = 2

L(f3) = 0

A(f3) = 1

L(f6) = 0

A(f6) = 1

L(f8) = 0

A(f8) = 1

L(f9) = 0

A(f9) = 1

f1

f2

f3

f4

f5

f6

f7

f8

f9

f0

v1

v2

v3

v4

v5

v6

v7

v8

v9

Page 30: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt8 - 4

Example: Vertex-Face Assignment

L(f1) = 2

A(f1) = 3

L(f4) = 1

A(f4) = 2

A(f5) = 2

L(f5) = 1

L(f2) = 0

A(f2) = 1

L(f0) = 4

A(f0) = 3

L(f7) = 1

A(f7) = 2

L(f3) = 0

A(f3) = 1

L(f6) = 0

A(f6) = 1

L(f8) = 0

A(f8) = 1

L(f9) = 0

A(f9) = 1

f1

f2

f3

f4

f5

f6

f7

f8

f9

f0

v1

v2

v3

v4

v5

v6

v7

v8

v9

Φ(v1) = f0Φ(v2) = f0Φ(v3) = f7Φ(v4) = f5Φ(v5) = f1Φ(v6) = f1Φ(v7) = f4Φ(v8) = f0Φ(v9) = f0

Page 31: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt9 - 1

Characterization

Thm 5: For a directed acyclic graph D = (V,A) withcombinatorial embedding F , f0 it holds:D is upward planar ⇔ D bimodal and ∃ consistent Φ

Page 32: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt9 - 2

Characterization

Thm 5: For a directed acyclic graph D = (V,A) withcombinatorial embedding F , f0 it holds:D is upward planar ⇔ D bimodal and ∃ consistent Φ

Proof:⇒ already clear

Page 33: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt9 - 3

Characterization

Thm 5: For a directed acyclic graph D = (V,A) withcombinatorial embedding F , f0 it holds:D is upward planar ⇔ D bimodal and ∃ consistent Φ

Proof:⇒ already clear

⇐ construct an st-digraph that contains D as spanningsubgraph:• insert edges in faces until they have single source and sink• prove acyclicity, planarity and bimodality

Page 34: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt10

Proof of Theorem 5

Assign labels sL, tL, sS , tS to each source/sink of each face f .Sequence σf .

S

SS

SS

SS

S

S

S

L

L

L

LL

f1

f2

f0

f3

σf1 := (S, S, L, S, L, S)σf2 := (L, S, S, S)σf3 := (S, S)σf0 := (L,L, S, L)L

Page 35: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt11 - 1

Proof of Theorem 5

• Cancel all sources and sinks: search for subsequence LSS.

S S S

S

LL

xy

z

f ′ f ′′

S S

S

L

x

y

z

f ′′ f ′

Page 36: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt11 - 2

Proof of Theorem 5

• Cancel all sources and sinks: search for subsequence LSS.

S S S

S

LL

xy

z

f ′ f ′′

S S

S

L

x

y

z

f ′′ f ′

• Invariants of construction: planarity, acyclicity, bimodality• In the outerface: select super source (resp. super sink) and

add edges to (from) other sources (resp. sinks)

Page 37: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt11 - 3

Proof of Theorem 5

• Cancel all sources and sinks: search for subsequence LSS.

S S S

S

LL

xy

z

f ′ f ′′

S S

S

L

x

y

z

f ′′ f ′

• Invariants of construction: planarity, acyclicity, bimodality• In the outerface: select super source (resp. super sink) and

add edges to (from) other sources (resp. sinks)

How to check whether a consistent assignment exists?

Page 38: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt12

Flow Network

Def: Flow network N(D,F , f0) = ((W,AN ); `;u; b)

• W = {v ∈ V | v is source or sink } ∪ F• AN = {(v, f) | v incident to f}• `(a) = 0 ∀a ∈ AN• u(a) = 1 ∀a ∈ AN

• b(q) =

1 ∀q ∈W ∩ V−(A(q)− 1) ∀q ∈ F \ {f0}−(A(q) + 1) q = f0

Page 39: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt13 - 1

Example

normal nodessources/sinks

Page 40: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt13 - 2

Example

normal nodessources/sinksface nodes

Page 41: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt13 - 3

Example

normal nodessources/sinksface nodes

−2

−3

0

−1

11 1

1

1

1

Page 42: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt13 - 4

Example

normal nodessources/sinksface nodes

−2

−3

0

−1

11 1

1

1

1

Thm 6:Let G be a directed acyclic digraph with embedding Fand outer face f0. The bipartite flow networkN(D,F , f0) admits a valid flow of value r (# ofsources/sinks) if and only if G has a consistentassignment of sources and sinks to faces.

Page 43: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt13 - 5

Example

normal nodessources/sinksface nodes

−2

−3

0

−1

11 1

1

1

1

• start with zero flow• search for augmenting path (r times for total of r sources

and sinks)

Page 44: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt14 - 1

Final Remarks

• O(rn) to decide whether consistent assignment exists• works also without fixed outer face f0: first compute all

faces as internal and then add two units of demand to aface vertex and test whether the total flow can beaugmented by two units. Do it for every face.

Page 45: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt14 - 2

Final Remarks

• O(rn) to decide whether consistent assignment exists• works also without fixed outer face f0: first compute all

faces as internal and then add two units of demand to aface vertex and test whether the total flow can beaugmented by two units. Do it for every face.

Thm 5: For a directed acyclic graph D = (V,A) withcombinatorial embedding F , f0 it holds:D is upward planar ⇔ D bimodal and ∃ consistent Φ

(recall)

Page 46: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt14 - 3

Final Remarks

• O(rn) to decide whether consistent assignment exists• works also without fixed outer face f0: first compute all

faces as internal and then add two units of demand to aface vertex and test whether the total flow can beaugmented by two units. Do it for every face.

Thm 5: For a directed acyclic graph D = (V,A) withcombinatorial embedding F , f0 it holds:D is upward planar ⇔ D bimodal and ∃ consistent Φ

+ algorithm to test the existence of assignment, imply:

(recall)

Page 47: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt14 - 4

Final Remarks

• O(rn) to decide whether consistent assignment exists• works also without fixed outer face f0: first compute all

faces as internal and then add two units of demand to aface vertex and test whether the total flow can beaugmented by two units. Do it for every face.

Thm 2:For a combinatorially embedded planar directedgraph it can be tested in O(n2) time whether it isupward planar.

Thm 5: For a directed acyclic graph D = (V,A) withcombinatorial embedding F , f0 it holds:D is upward planar ⇔ D bimodal and ∃ consistent Φ

+ algorithm to test the existence of assignment, imply:

(recall)

Page 48: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt14 - 5

Final Remarks

• O(rn) to decide whether consistent assignment exists• works also without fixed outer face f0: first compute all

faces as internal and then add two units of demand to aface vertex and test whether the total flow can beaugmented by two units. Do it for every face.

Thm 2:For a combinatorially embedded planar directedgraph it can be tested in O(n2) time whether it isupward planar.

Thm 5: For a directed acyclic graph D = (V,A) withcombinatorial embedding F , f0 it holds:D is upward planar ⇔ D bimodal and ∃ consistent Φ

+ algorithm to test the existence of assignment, imply:

The layout can be constructed in the same time: O(n) toaugment to st-digraphs and O(n) to draw the st-digraph

(recall)

Page 49: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt15 - 1

Discussion

Page 50: Flow Methods: Upward Planarity Algorithms for Graph

Torsten Ueckerdt15 - 2

Discussion

• There exists a fixed-parameter tractable algorithm to testupward planarity, with parameter being the number oftriconnected components [Healy, Lynch SOFSEM 2005]

• The decision of Theorem 2 can be done in O(n+ r1.5)time where r = # sources/sinks [Abbasi, Healy, Rextin IPL 2010]

• many related concepts have been studiedrecently: quasi-planarity, upward drawings ofmixed graphs