graph visualization: topology-shape-metrics

Post on 14-Mar-2022

12 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Graph Visualization:

Topology-Shape-Metrics

Topology-Shape-Metrics

1. Background

โ€ข Planarity

โ€ข Topology

2. The topology-shape-metrics approach

1. Topology

2. Shape

3. Metrics

3. Remarks

Background: Planarity

7

5

1

9

6

2

3

4

0

8

A graph drawing

is planar if it has no edge crossings.

7

5

1

9

6

2

3

4

0

8

A planar graph drawing A non-planar graph drawing

Edge crossing

Note: Planar drawings make beautiful pictures

Mary Bob

Peter

Jon

DavidF

Alan

Joseph

Judy

Albert

DavidE

Peter

Mary

Jon

DavidF

Alan

Joseph

Bob Judy

Albert

DavidE

Bad picture Good picture

A graph

is planar

if it can be drawn without edge crossings.

0 1 2 3 4 5 6 7 8 9

0 1 1

1 1 1 1

2 1 1 1

3 1 1

4 1 1 1 1

5 1 1 1 1

6 1 1

7 1 1 1

8 1 1 1

9 1 1

A planar graph ๐‘ฎ๐Ÿ

0 1 2 3 4 5

0 1 1 1

1 1 1 1

2 1 1 1

3 1 1 1

4 1 1 1

5 1 1 1

A nonplanar graph ๐‘ฎ๐Ÿ

7

5

1

9

6

2

3

4

0

8

Lemma:

๐‘ฎ๐Ÿ is planar.

0 1 2 3 4 5 6 7 8 9

0 1 1

1 1 1 1

2 1 1 1

3 1 1

4 1 1 1 1

5 1 1 1 1

6 1 1

7 1 1 1

8 1 1 1

9 1 1

Proof

A graph ๐‘ฎ is non-planar if every drawing of ๐‘ฎ has edge crossings.

0 1 2 3 4 5

0 1 1 1

1 1 1 1

2 1 1 1

3 1 1 1

4 1 1 1

5 1 1 1

A nonplanar graph ๐‘ฎ๐Ÿ

Kuratowskiโ€™s Theorem (1930)

A graph is planar if and only if it does not contain a subgraph that is a subdivision of ๐‘ฒ๐Ÿ“ or ๐‘ฒ๐Ÿ‘,๐Ÿ‘.

๐‘ฒ๐Ÿ“ (the complete graph on 5

vertices) subdivision

๐‘ฒ๐Ÿ‘,๐Ÿ‘ (complete bipartite graph on 6

vertices) subdivision

Note: There are many beautiful theorems about planar graphs

Kuratowskiโ€™s Theorem (1930)

A graph is planar if and only if it does not contain a subgraph that is a subdivision of ๐‘ฒ๐Ÿ“ or ๐‘ฒ๐Ÿ‘,๐Ÿ‘.

Note: There are many beautiful theorems about planar graphs

Corollary

๐‘ฎ๐Ÿ is non-planar 0 1 2 3 4 5

0 1 1 1

1 1 1 1

2 1 1 1

3 1 1 1

4 1 1 1

5 1 1 1

A nonplanar graph ๐‘ฎ๐Ÿ

Proof:

๐‘ฎ๐Ÿ is ๐‘ฒ๐Ÿ‘,๐Ÿ‘.

Theorem: A graph is planar if and only if each of its triconnected components is

planar.

Note: There are many beautiful theorems about planar graphs

Theorem: (Appel-Haken) A planar graph can be colored in 4 colors.

Theorem: (from Euler) For a planar graph ๐‘ฎ = (๐‘ฝ, ๐‘ฌ), ๐‘ฌ โ‰ค ๐Ÿ‘ ๐‘ฝ โˆ’ ๐Ÿ”. If ๐‘ฌ = ๐Ÿ‘ ๐‘ฝ โˆ’ ๐Ÿ”, then ๐‘ฎ is triconnected and each face of the

embedding of ๐‘ฎ has 3 edges.

Theorem: (Steinitz) For every triconnected planar graph ๐‘ฎ, there is a convex

polyhedron ๐‘ท in 3D such that the vertex-edge graph of ๐‘ท is

isomorphic to ๐‘ฎ.

Theorem: (Lipton-Tarjan separator) For every planar graph ๐‘ฎ with ๐’ vertices, there is set of ๐‘ถ ๐’ vertices whose removal divides the graph into

components of size at most ๐Ÿ๐’

๐Ÿ‘.

Remarks: Planar graphs and real-world graphs

Most real-world graphs are not planar

But most are โ€œnearlyโ€ planar in that deletion of ๐’(๐’) edges gives a planar graph

โ€ข scale-free networks are locally dense and globally sparse

Planarity testing algorithms

Hopcroft-Tarjan planarity testing algorithm (1974)

Tests whether a graph is planar or not, in linear time

Very complicated algorithm; implementation difficult

โ€ข First published version incorrect; corrected by Deo (1976)

โ€ข Most implementations incorrect

โ€ข First correct implementation (I believe) 1994.

Many subsequent planarity testing algorithms

Lempel-Even-Cederbaum 1966

Booth-Lueker 1976

Rosensthiel-de Frayssieux 1990

Hsu/Boyer-Myvold 2000

Note:

All these planarity testing algorithms are efficient and effective, but none is elegant.

Finding an elegant linear time planarity testing algorithm is still an unsolved

problem.

Background: Topology

Graph

(topological) Embedding

Graph drawing

No geometry, just a combinatorial object

A geometric and visual object

A graph drawing divides

the plane into regions

called faces.

๐‘ญ๐Ÿ

๐‘ญ๐ŸŽ ๐‘ญ๐Ÿ

๐‘ญ๐Ÿ’

๐‘ญ๐Ÿ‘

๐‘ญ๐Ÿ

๐‘ญ๐ŸŽ

๐‘ญ๐Ÿ

๐‘ญ๐Ÿ‘ ๐‘ญ๐Ÿ’

๐‘ญ๐Ÿ“

The faces plus their adjacencies form

the dual graph of the drawing.

๐‘ญ๐Ÿ

๐‘ญ๐ŸŽ

๐‘ญ๐Ÿ

๐‘ญ๐Ÿ‘ ๐‘ญ๐Ÿ’

๐‘ญ๐Ÿ“

๐‘ญ๐Ÿ‘ ๐‘ญ๐Ÿ

๐‘ญ๐ŸŽ

๐‘ญ๐Ÿ’ ๐‘ญ๐Ÿ“

๐‘ญ๐Ÿ

Definition:

Two drawings of a graph are topologically equivalent if there is a homeomorphism

of the plane/sphere that maps one to the other.

1

3 5

8 4 6

2 0

7

1

3

5

8

4

6

2

0

7

1

3 5

8

4 6

2 0

7

Alternative definitions:

Two drawings of a graph are topologically equivalent if

1. they have the โ€œsameโ€ dual graph, or alternatively

2. they have the same clockwise circular ordering of edges around each vertex.

Topologically equivalent Not topologically equivalent

1

3 5

8 4 6

2 0

7

1

3

5

8

4

6

2

0

7

0 8,1,5

1 5,0,2,6

2 1,3

3 6,2,7

4 8,5,6

5 8,0,1,4

6 4,1,3,7

7 6,3

8 0,5,4

0 5,8,1

1 6,5,0,2

2 3,1

3 7,6,2

4 8,5,6

5 4,8,0,1

6 4,1,3,7

7 6,3

8 4,0,5

Same

topological

embedding

Same clockwise circular

orderings of edges around each vertex

Definition:

Two drawings of a graph are topologically equivalent if there is a homeomorphism

of the plane/sphere that maps one to the other.

Definition:

A (topological) embedding of a graph ๐‘ฎ is an equivalence

class of drawings of ๐‘ฎ under topological equivalence.

Data structure for planar embeddings:

a) List of vertices.

b) For each vertex ๐’–, a circular list of vertices ๐’— adjacent to ๐’–.

1

3 5

8 4 6

2 0

7

0 8,1,5

1 5,0,2,6

2 1,3

3 6,2,7

4 8,5,6

5 8,0,1,4

6 4,1,3,7

7 6,3

8 0,5,4

Alternative definitions:

An embedding consists of

1. A graph, โ€œplusโ€ the dual graph.

2. A graph, plus a clockwise circular ordering of

edges around each vertex.

A non-planar embedding can be planarized by placing dummy vertices at the edge

crossings.

planarize

planarize

A non-planar embedding can be planarized by placing dummy vertices at the edge

crossings.

planarize

Note:

โ€ข The concept of planarization allows us to apply terminology, definitions, and

data structures about planar embeddings to non-planar embeddings.

โ€ข If the number of crossing points is small, then planarization might not increase

asymptotic time complexity of algorithms

โ€ข Normally, we use planarization to give a data structure for a non-planar

embedding

Planar embedding algorithms

Most planarity testing algorithms โ€œcan be adjustedโ€ to output a planar

embedding of a planar graph in linear time.

All these algorithms are efficient and effective; none is elegant.

3. Graph drawings

A drawing of a graph ๐‘ฎ = (๐‘ฝ, ๐‘ฌ) consists of

โ€ข a location ๐’‘(๐’–) for each vertex ๐’–, and

โ€ข a Jordan arc ๐’„(๐’–, ๐’—) for each edge (๐’–, ๐’—) such that the endpoints

of ๐’„(๐’–, ๐’—) are ๐’‘(๐’–) and ๐’‘(๐’—).

โ€ข (plus a lot of nondegeneracy conditions)

There are many kinds of graph drawings

Grid drawing: vertices (and edge bends?) are located at integer grid points

Polyline drawing: edges are polylines

Straight-line drawing: edges are straight line segments

Orthogonal drawing: edges are polylines made up of vertical and horizontal

line segments

โ€ฆ.

โ€ฆ..

5

2 0 1

8

3 7 4 6

Straight-line drawing

5

2 0 1

8

3 7 4 6

Polyline drawing

A drawing of a graph ๐‘ฎ = (๐‘ฝ, ๐‘ฌ) consists of

โ€ข a location ๐’‘(๐’–) for each vertex ๐’–, and

โ€ข a Jordan arc ๐’„(๐’–, ๐’—) for each edge (๐’–, ๐’—) such that the endpoints

of ๐’„(๐’–, ๐’—) are ๐’‘(๐’–) and ๐’‘(๐’—).

5

2 0

1

8

3

7

4

6

Orthogonal drawing

5

2

0 1

8

3 7 4 6

Grid drawing

A drawing of a graph ๐‘ฎ = (๐‘ฝ, ๐‘ฌ) consists of

โ€ข a location ๐’‘(๐’–) for each vertex ๐’–, and

โ€ข a Jordan arc ๐’„(๐’–, ๐’—) for each edge (๐’–, ๐’—) such that the endpoints

of ๐’„(๐’–, ๐’—) are ๐’‘(๐’–) and ๐’‘(๐’—).

5

2

1

8

3

7

4

6

0

Orthogonal grid drawing

A drawing of a graph ๐‘ฎ = (๐‘ฝ, ๐‘ฌ) consists of

โ€ข a location ๐’‘(๐’–) for each vertex ๐’–, and

โ€ข a Jordan arc ๐’„(๐’–, ๐’—) for each edge (๐’–, ๐’—) such that the endpoints

of ๐’„(๐’–, ๐’—) are ๐’‘(๐’–) and ๐’‘(๐’—).

Graph

(topological) Embedding

Graph drawing

No geometry, just a combinatorial object

A geometric and visual object

A topological but not geometric object

Topology-shape-metrics approach

Topology-shape-metrics approach:

Input: a graph ๐‘ฎ

Algorithm:

1. Topology: Compute a good topological

embedding of ๐‘ฎ

2. Shape: Compute a good orthogonal

shape for this topological embedding

3. Metrics: Compute a good orthogonal grid

drawing of ๐‘ฎ

Output: an orthogonal grid drawing of ๐‘ฎ

Aim: produce an embedding with few edge crossings

1. Topology-shape metrics method

Input: a graph ๐‘ฎ = (๐‘ฝ, ๐‘ฌ)

a) Compute a planar subgraph ๐‘ฎโ€ฒ = ๐‘ฝ, ๐‘ฌโ€ฒ , where ๐‘ฌโ€ฒ is a subset of ๐‘ฌ, such that ๐‘ฌโ€ฒ is as large as possible.

b) Compute a planar embedding ๐‘ฎโ€ฒโ€ฒ of ๐‘ฎโ€ฒ.

c) Insert the edges of ๐‘ฌ โˆ’ ๐‘ฌโ€ฒ into ๐‘ฎโ€ฒโ€ฒ, creating as few crossings as

possible, to create an embedding ๐‘ฎโ€ฒโ€ฒโ€ฒ of ๐‘ฎ.

Output: an embedding of ๐‘ฎ with few crossings

Use a maximum-planar-subgraph method

We need solutions for a difficult problem:

The most successful approach to MPS so far is integer linear programming

Note

MPS is NP-complete

Many heuristic approaches have been investigated, implemented,

and tested over at least the last 30 years

Maximum Planar Subgraph (MPS)

Input: a graph ๐‘ฎ

Output: a planar subgraph of ๐‘ฎ with a maximum number of edges.

Integer Linear Program for the Maximum Planar Subgraph problem

Given a graph ๐‘ฎ = (๐‘ฝ, ๐‘ฌ):

Variables

๐’™๐’† for each edge ๐’† โˆˆ ๐‘ฌ

Objective

Maximize ๐’™๐’†๐’†โˆˆ๐‘ฌ

Constraints

a) ๐’™๐’† โˆˆ ๐ŸŽ, ๐Ÿ

b) For each Kuratowski subgraph ๐‘ฒ = ๐‘ฝ๐‘ฒ, ๐‘ฌ๐‘ฒ of ๐‘ฎ:

๐’™๐’†๐’†โˆˆ๐‘ฌ๐‘ฒ

โ‰ค ๐‘ฌ๐‘ฒ

Interpetation:

๐’™๐’† = ๐Ÿ if ๐’† โˆˆ ๐‘ฌโ€ฒ๐ŸŽ otherwise

Algorithm:

Use a traditional โ€œbranch&cutโ€ approach, with cutting planes from theorems on planar graphs.

1. Topology: Compute a good topological embedding of ๐‘ฎ

Input: a graph ๐‘ฎ = (๐‘ฝ, ๐‘ฌ)

a) Compute a planar subgraph ๐‘ฎโ€ฒ = ๐‘ฝ, ๐‘ฌโ€ฒ , where ๐‘ฌโ€ฒ is a subset of ๐‘ฌ, such that ๐‘ฌโ€ฒ is as large as possible.

b) Compute a planar embedding ๐‘ฎโ€ฒโ€ฒ of ๐‘ฎโ€ฒ.

c) Insert the edges of ๐‘ฌ โˆ’ ๐‘ฌโ€ฒ into ๐‘ฎโ€ฒโ€ฒ, creating as few crossings as possible, to create an embedding ๐‘ฎโ€ฒโ€ฒโ€ฒ of ๐‘ฎ.

Output: an embedding of ๐‘ฎ with few crossings

Use planar embedding algorithms

- For example, a variation on the Hopcroft-Tarjan planarity algorithm

1. Topology: Compute a good topological embedding of ๐‘ฎ

Input: a graph ๐‘ฎ = (๐‘ฝ, ๐‘ฌ)

a) Compute a planar subgraph ๐‘ฎโ€ฒ = ๐‘ฝ, ๐‘ฌโ€ฒ , where ๐‘ฌโ€ฒ is a subset of ๐‘ฌ, such that ๐‘ฌโ€ฒ is as large as possible.

b) Compute a planar embedding ๐‘ฎโ€ฒโ€ฒ of ๐‘ฎโ€ฒ.

c) Insert the edges of ๐‘ฌ โˆ’ ๐‘ฌโ€ฒ into ๐‘ฎโ€ฒโ€ฒ, creating as few crossings as possible, to create an embedding ๐‘ฎโ€ฒโ€ฒโ€ฒ of ๐‘ฎ.

Output: an embedding of ๐‘ฎ with few crossings

Use planar shortest path in the dual

To insert an edge

(๐’–, ๐’—) โˆˆ ๐‘ฌ โˆ’ ๐‘ฌโ€ฒ into

๐‘ฎโ€ฒโ€ฒ:

Construct the dual

graph of ๐‘ฎโ€ฒโ€ฒ

Let ๐’‡๐’– be the set of

faces containing ๐’–

Let ๐’‡๐’— be the set of

faces containing ๐’—

Route (๐’–, ๐’—) via a

shortest path from

๐’‡๐’– to ๐’‡๐’—.

1

3 5

8 4 6

2 0

7

1

3 5

8 4 6

0

7

1

3

5

8 4 6

2 0

7

1

3 5

8 4 6

2 0

7

1

5

8 4 6

2 0

7

1 2

1

5

8 4

6

0

v

u

Topology-shape-metrics approach:

Input: a graph ๐‘ฎ

Algorithm:

1. Topology: Compute a good topological

embedding of ๐‘ฎ

2. Shape: Compute a good orthogonal

shape for this topological embedding

3. Metrics: Compute a good orthogonal grid

drawing of ๐‘ฎ

Output: an orthogonal grid drawing of ๐‘ฎ

Aim: give shape with a small number of edge bends.

Assumption: the degree of each vertex is at most 4.

The shape of a directed orthogonal edge is the sequence of North/South/East/West turns.

๐’–

๐’—

Shape of (๐’–, ๐’—):๐‘ฌ๐‘ต๐‘ฌ๐‘ต๐‘ฌ๐‘บ๐‘ฌ

East

East

East

East N

ort

h

No

rth

So

uth

The shape of an orthogonal drawing

consists of the shape of each edge

(after directing edges arbitrarily)

1

3 5

8

4 6

2 0

7

05 WSE

10 W

12 E

16 S

23 ESW

45 W

48 NW

58 N

64 W

73 S

76 WSW

80 N

2. Shape:

Compute a good orthogonal shape for the topological embedding output

from the topology step.

We want a small number of bends

Minimum Bends Problem

Input: An embedding ๐‘ฎ

Output: A shape for ๐‘ฎ with a minimum number of bends.

Surprising result

Theorem (Tamassia, ~1987)

The Minimum Bends Problem can be solved in polynomial time.

๐‘ถ ๐’๐Ÿ.๐Ÿ•๐Ÿ“ ๐’๐’๐’ˆ๐’

Tamassiaโ€™s algorithm to give a shape with a minimum total number of bends

5

2 0

8

3

7

โ€ข Note that ๐œ‹

2 angles in a drawing satisfy some

linear constraints

- The sum of angles around a face is

๐Ÿ ๐’‚ + ๐’ƒ โ€“ ๐Ÿ’๐…

๐Ÿ , where ๐’‚ is the number of

vertices and ๐’ƒ is the number of bends in the face.

- The sum of angles around a vertex is ๐Ÿ’๐…

๐Ÿ.

- โ€ฆ plus other constraints from theorems on planar graphs

- โ€ฆ

- โ€ฆ

โ€ข These constraints can be modelled as a minimum flow problem

โ€ข We can solve the minimum flow problem in polynomial time.

Alternative method to give a shape with a small number of bends

1. Create a visibility representation of the input embedding

2. Adjust the visibility representation to give an orthogonal shape

Runs in linear time

Relatively elegant

Does not give a minimum total number

of bends

But guarantees that the number of

bends on an edge is at most 4. 5

2 0

3

7

5

2 0

3

7

Topology-shape-metrics approach:

Input: a graph ๐‘ฎ

Algorithm:

1. Topology: Compute a good topological

embedding of ๐‘ฎ

2. Shape: Compute a good orthogonal

shape for this topological embedding

3. Metrics: Compute a good orthogonal grid

drawing of ๐‘ฎ

Output: an orthogonal grid drawing of ๐‘ฎ

Aim: give a drawing with good vertex resolution

Metrics step: Use VLSI-inspired compaction methods to get a drawing on a small grid

Compaction in the ๐’™ direction

1. Construct a directed visibility graph ๐‘ฏ on the dual with source at the left and

sink at the right.

2. For each vertex ๐’– in ๐‘ฏ, find a longest path in ๐‘ฏ from the source to ๐’–.

3. Assign ๐’š-coordinates using path-length from the source.

5

2 0

1

8

3

7

4

6

Compaction in the ๐’™ direction

1. Construct a directed visibility graph ๐‘ฏ on the dual with source at the left and

sink at the right.

2. For each vertex ๐’– in ๐‘ฏ, find a longest path in ๐‘ฏ from the source to ๐’–.

3. Assign ๐’š-coordinates using path-length from the source.

Similarly compact in the ๐’š-direction.

5

2 0

1

8

3

7

4

6

Remarks

Topology-shape-metrics approach

Good things

โ€ข Works well on small graphs

โ€ข Relatively fast (varies from ๐‘ถ(๐’) to ๐‘ถ ๐’๐Ÿ๐’๐’๐’ˆ ๐’ )

โ€ข Validated readability

โ€ข Can be adjusted to handle vertices of large degree and large size

โ€ข Can be adjusted for some constraints

Kle

in

Kle

in

Topology-shape-metrics approach

Bad things

โ€ข Large drawings often look bad

(poor faithfulness?)

โ€ข Very difficult to code

Note: topology-shape-metrics is seldom used commercially.

top related