planar graphs algorithms and networks. planar graphs2 can be drawn on the plane without crossings...

32
Planar graphs Algorithms and Networks

Upload: luca-leston

Post on 01-Apr-2015

223 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs

Algorithms and Networks

Page 2: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs2

Planar graphs

• Can be drawn on the plane without crossings• Plane graph: planar graph, given together with an

embedding in the plane• Many applications…• Questions:

– Testing if a graph is planar

– Finding a nice drawing of a planar graph

– Solving problems for planar graphs

Page 3: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs3

Some notions

• Faces

• Exterior face

• Interior faces

• Each edge is incident to 2 faces

Page 4: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs4

The smallest graphs that are not planar

• K5, K3,3

Page 5: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs5

Kuratowski / Wagner

• A graph is planar if and only if it does not contain the K5 and the K3,3 as a homeomorphic subgraph / as a minor.

• Minor: H is a minor of G, if H can be obtained from G by a series of 0 or more deletions of vertices, deletions of edges, and contraction of edges.

• Does not yield fast recognition algorithm!

Page 6: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs6

Euler’s theorem

• Let G be a connected plane graph with n vertices, m edges, and f faces. Then n + f – m = 2.

• Proof. By induction. – True if m=0.

– If G has a circuit, then delete an edge and …

– If G has a vertex v of degree 1, then delete v and …

• …

Page 7: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs7

Euler’s theoremCorollaries

• If G is a connected plane graph with no parallel edges and no self-loops, with n > 1, then m 3n-6.– Every face `has’ at least three edges; each edge

`is on’ two faces, or twice on the same face.

• Every plane graph with no parallel edges and no self-loops has a vertex of degree at most 5.

Page 8: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs8

Duality

• The dual G* of a plane graph G– A vertex in G* for each face of G– An edge in G* when faces share an edge in G

Page 9: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs9

Drawings of planar graphs

• Different types• Vertices are:

– Points in 2-dimensional space– Rectangles, other objects

• Edges are– Straight lines– Curves– Lines with bends– Adjacencies or intersections of objects

Usual modelUsual model

Page 10: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs10

Drawing planar graphs

In steps:1. Test if G is planar, and

2. Find for each vertex, a clockwise ordering of its incident edges, such that these orderings allow a planar embedding, and then

3. Assign coordinates to vertices

Page 11: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs11

Planarity testing: reduction to biconnected graphs

• First, suppose G is biconnected.– G is biconnected, if for each vertex v, G-v is connected.– A biconnected component of G is a maximal subgraph

that is biconnected.– A graph is planar, if and only if each of its biconnected

components is planar.• Each biconnected component can be drawn with any vertex on

its exterior face.• Build drawing of G by putting drawings of biconnected

components together.• Easier non-constructive argument: G has a K5 or K3,3 minor, iff

a biconnected component of G has such a minor.

Page 12: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs12

Cycles with pieces

• Take a cycle C in G.• Divide edges not on C of G into classes:

– e and e’ in the same class if there is a path starting with e, ending with e’, using no vertices on C as intermediate points

– A class forms a piece.

• Pieces are– A single edge between two vertices on C

– A connected graph with at least one vertex not on C

Page 13: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs13

Separating cycles

• A cycle is separating if it has at least two pieces.

• Plan:– Find separating cycle C (how?)– Test for each piece + C if it is planar (recursion)– Determine for each piece if it has to be drawn

inside or outside C (matching problem; details follow).

Page 14: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs14

Finding a separating cycle

• Find a cycle C.

• If C separating: done.

• Otherwise, let P be the unique piece.

• If P is a path: G is planar: done.

• Otherwise:– Take two consecutive attachments v, w of P in the circular

ordering of C, and let Q be the part of C between the attachments without another attachment.

– Take a path R between v and w in P avoiding other attachments

– C – Q + R is a separating cycle

Page 15: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs15

The interlacement graph

• Pieces can be `inside’ or `outside’ the cycle

• Build interlacement graph– Each piece is a vertex in interlacement graph– Pieces are adjacent, when they cannot be at the

same side (look to attachments)

Page 16: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs16

Theorem

• Let C be a separating cycle in G. G is a planar graph, if and only if– For each piece P, C+P is planar.– The interlacement graph is bipartite.

Gives a polynomialtime algorithm!

Gives a polynomialtime algorithm!

Page 17: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs17

Interlacement graph can be built in O(n2) time

• For each piece– Partition C into intervals with respect to

attachments– For each other piece

• Look whether all attachments are in the same interval

• If not, they conflict.

Page 18: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs18

Algorithm

• Find a cycle C• Test if C is separating.• If not, use method to build separating cycle C’.• Find pieces of C’.• Build interlacement graph.• Test if interlacement graph is bipartite. If not: G is

not planar, stop.• Otherwise, test for each piece P, recursively, if

P+C’ is planar.

Page 19: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs19

Time

• O(n3).

• Can be done faster: O(n) algorithms exist.

• Finding clockwise orderings of edges per vertex can also be done: several details…

Page 20: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs20

Force directed methods

• Method for arbitrary graphs

• Uses physical analogy:– Force system– Method to find equilibrium state

• Advantages:– Relatively easy to understand and implement– Often reasonably nice results

Page 21: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs21

Springs and electrical forces method

• Edges are springs

• Vertices repel each other

• Force on vertex:– fuv is force on spring

– guv is repelling force

Vu

uvEvu

uv gfvF},{

)(

Page 22: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs22

Spring force

• Assume some `wanted length’ of an edge luv. (E.g., 1.)

• Spring wants to assume length luv; force is proportional to difference with luv.

• Choose some stiffness of the spring kuv.’• Force in x-direction is (y-direction similar):

),(

*),(},.{ vud

xxlvudk vu

Evuuvuv

Page 23: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs23

Repelling force

• Vertices are repelling particles

• Follow inverse square law

• k’uv is strength of repulsion (choose some number, e.g., experimentally)

• Repelling force of v in x-direction:

vuVu

vuuv

vud

xx

vud

k

,2 ),(),(

' Similar in y-direction

Page 24: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs24

Search for equilibrium

• Position where all vertices have a force of 0 towards them (sum of spring and repelling forces)

• Springs have lengths of edges go to desired length

• Repelling has vertices not too close together

Page 25: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs25

Searching for equilibrium

• Numerical techniques• Simple algorithm:

– Take for each vertex a random position

– Repeat:• Compute for each vertex its force

• Move all vertices to new position depending on their forces

Until in sufficient rest

• Faster algorithms exist

Page 26: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs26

Barycenter method

• Tutte, 1960

• Differences with force method– No repelling forces

– luv = 0

– Stiffness is 1– Vertices at exterior face get fixed positions

Page 27: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs27

Force on a vertex

Evu

vu ppvF},{

)()(

Where pu is the position of u on the planeIf v is a free vertex

Page 28: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs28

Finding equilibrium

• System of forces can be written as set of linear equations

• Fast converging algorithms

• For planar graphs, system can be solved in O(n1.5) time

Page 29: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs29

Barycenter draw pseudocode

• Place all fixed vertices at corners of polygon around origin, and all free vertices on origin

• Repeat– For each free vertex v do

• x(v) = 1/degree(v) * ((u,v) in E) x(u)

• y(v) = 1/degree(v) * ((u,v) in E) y(u)

until sufficient convergence

Page 30: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs30

Theorem of Tutte

• If G is a triconnected planar graph, then this method yields a planar drawing of G.– Assuming …– In practice, layers become smaller in the inside

• Generalizations with more complicated forces sometimes also have this property

• If G is not triconnected, then we can make it triconnected by adding edges

Page 31: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs31

Grid drawings

• Many results on planar drawings, e.g.,

• Theorem (Schnyder, 1990) Every planar graph G has a plane drawing, such that– Each edge is a straight line– Vertices are mapped to pairs of integers in {0,1,

…,n – 2} * {0,1, …, n – 2}

Page 32: Planar graphs Algorithms and Networks. Planar graphs2 Can be drawn on the plane without crossings Plane graph: planar graph, given together with an embedding

Planar graphs32

Many other results

• Embeddings with small areas and few bends per edge

• Drawings where vertices are represented by rectangles with an edge if rectangles touch

• …