Approximating the of Outerplanar Graphs

y y z

Ra jeev Govindan Michael A Langston and Xudong Yan

Abstract

Pathwidth is a wellknown NP metric Only very simple classes

of graphs such as trees are known to p ermit practical pathwidth algorithms We

present a technique to approximate the pathwidth of outerplanar graphs Our al

gorithm works in linear time is genuinely practical and pro duces solutions at most

three times the optimum

Keywords algorithms pathwidth outerplanar graphs approximation de

comp osition

Introduction

Pathwidth was dened by Rob ertson and Seymour in their seminal series of pap ers on Graph

Minors Since then this metric has found application in many areas ranging from circuit

layout to natural language pro cessing Determining pathwidth is NP Complete Thus it

is natural to search for fast approximation algorithms No p olynomialtime relative approxima

tion algorithm one whose solution is within a multiplicative constant of the optimum is known

for the general problem Moreover no p olynomialtime absolute approximation algorithm one

whose solution is within an additive constant of the optimum can exist unless P NP

The main result of this pap er is a practical relative approximation algorithm for the path

width problem on outerplanar graphs Since outerplanar graphs have two or less

the metho ds in can in principle b e used to compute the pathwidth exactly in p olynomial

time This is not a realistic option however b ecause of the high of the p olynomial and

its enormous multiplicative constant In contrast our algorithm approximates the pathwidth

to within a factor of three of the optimum in practical linear time

This research is supp orted in part by the Oce of Naval Research under contract NJ

y

Department of Computer Science University of Tennessee TN

z

Prism Solutions Inc Hamlin Court Sunnyvale CA

Our Approach

Tree and Path Decomp ositions

We consider only connected graphs without lo ops or multiple edges

A tree decomposition of a graph G is a pair T Y where T is a tree and Y fY j i V T g

i

is a collection of subsets of V G such that i for each edge e E G some Y contains b oth

i

endp oints of e and ii for all i j k V T if j is on the path b etween i and k in T Y Y Y

i k j

The width of a tree decomp osition T Y is one less than the size of the largest set in Y The

treewidth of G denoted tw G is the smallest width of all its tree decomp ositions

A path decomposition of G is a sequence X X of subsets of V G such that i for

1 r

each edge e E G some X contains b oth endp oints of e and ii for i j k r

i

X X X The width of a path decomp osition X X is one less than the size of the

i k j 1 r

largest set X i r The pathwidth of G denoted pw G is the smallest width of all its

i

path decomp ositions

A Conversion Pro cedure

Path decomp ositions can b e derived from tree decomp ositions We employ such a pro cedure

tdp d and prove its correctness It requires a routine to construct optimal path decomp osi

tions of trees For this we use the lineartime metho d presented in Since the runtime of

tdp d is dominated by the time sp ent in this routine tdp d runs in linear time as well

Pro cedure tdp d

Input A tree decomp osition T Y of a graph G

Output A path decomp osition of G

b egin pro cedure

X X an optimal path decomp osition of T

1 r

for i r do

[

Y P

j i

j 2X

i

output P P

1 r

end pro cedure

Theorem Let T Y denote a widtht tree decomp osition of a graph G Then tdp dT Y

returns a path decomp osition of G with width no more than t pw T

Pro of Let X X denote the optimal path decomp osition of T constructed in tdp d

1 r

[

and let P P denote the output of tdp d Then for i r jP j j Y j

1 r i j

j X

i

t pw T Thus the width condition is satised and we only need to check that

P P is a valid path decomp osition of G

1 r

It is easy to see that P P covers all edges in G We prove by contradiction that

1 r

P P has the intersection prop erty If the intersection prop erty do es not hold then for

1 r

some i j k r there is a vertex v in P P that is not in P Since v P P

i k j i k

there must exist l X and m X such that v b elongs to Y and Y Consider the subsets

i k l m

[ [

V and V of V T where V X X and V X X The intersection prop erty

1 2 1 p j 2 p j

pj pj

of X X implies that V and V are disjoint Moreover there is no edge in T connecting

1 r 1 2

V and V b ecause some X must contain b oth endp oints of such an edge contradicting the

1 2 q

disjointness of V and V Thus every path b etween V and V in T contains a vertex from

1 2 1 2

X In particular the path b etween l and m must contain a vertex say h from X By the

j j

intersection prop erty of T Y v Y Since h X Y P and v P a contradiction

h j h j j

Path Decomp ositions of Outerplanar Graphs

A graph is outerplanar if it has a planar embedding with all vertices lying on a single face

Outerplanar graphs have treewidth at most two In this section we develop an algorithm that

for an outerplanar graph G constructs an optimal tree decomp osition T Y with pw T

pw G By Theorem running tdp d on T Y pro duces a path decomp osition with width

at most pw G

We say that T Y is simple if T Y has width at most two T is a subgraph of G and

v Y for all v V T Since our algorithms use vertex lab els we insist that the lab els of

v

V T resp ect those of V G Because pathwidth cannot b e increased by taking a subgraph

if T Y is simple then pw T pw G Our algorithm constructs T Y by combining tree

decomp ositions of Gs subgraphs Let T Y and T Y denote tree decomp ositions of

subgraphs G and G resp ectively Supp ose that V T and V T are disjoint and that there

are vertices u V T and v V T such that all the vertices in V G V G are in b oth

Y and Y Then we may obtain a tree decomp osition of G G by adding the edge uv This

u v

decomp osition is simple if T Y and T Y are simple and if uv E G E G

Biconnected Graphs

We concentrate initially on biconnected graphs those without cut p oints

Lemma Let G b e biconnected outerplanar and of order at least three Let v denote a vertex

in G Then G contains a path P with at least two edges and with endp oints w and x such

that the following conditions hold

G P fw xg is biconnected outerplanar and contains v

w and x are adjacent in G and hence in G P fw xg and

every edge in G is either in P or in G P fw xg

Pro of If G is a then the lemma is satised by setting P to G fuv g where u is a vertex

adjacent to v Otherwise x an outerplanar layout of G Let E denote the set of internal

i

edges of G those not on the external face Orient the layout so that some edge e is rightmost

and some edge e is leftmost in E If v is to the left of e then setting P to the path consisting

i

of all the external edges to the right of e satises the lemma Otherwise set P to the path

containing all the external edges to the left of e

If a path P contains at least two edges and has endp oints w and x then it has a widthtwo

tree decomp osition T Y such that T P fw xg and for i V T Y fx i j g where j

i

is the neighbor of i on w s side the sets Y actually form a path decomp osition of P We call

i

T Y a w extensible tree decomp osition of P Figure shows a path and its w extensible tree

decomp osition The sets Y are shown inside the ovals i

x 1 2 3 4 5 w

{x,1,2} {x,2,3} {x,3,4} {x,4,5} {x,5,w}

Figure A path and its w extensible tree decomp osition

Note that for every edge ij E P either fi j g Y or fi j g Y We use the notion

i j

of extensibility to derive b coptd our algorithm to construct simple tree decomp ositions of

biconnected outerplanar graphs

Pro cedure b coptd

Input A biconnected outerplanar graph G of order two or more and a vertex v in G

Output A simple tree decomp osition T Y of G with T spanning G fv g

b egin pro cedure

if jV Gj

then b egin

u the vertex adjacent to v

T fug and Y fY g where Y fu v g

u u

end

else b egin

P a path b etween some two vertices w and x that satises Lemma

0 0

T Y b coptdG P fw xg v

0

if fw xg Y

w

then b egin

e the edge incident on w in P

00 00

T Y the w extensible tree decomp osition of P

end

else b egin

e the edge incident on x in P

00 00

T Y the xextensible tree decomp osition of P

end

0 00 0 00

T T T feg and Y Y Y

end

output T Y

end pro cedure

At this p oint we may as well assume that v is chosen at random A sp ecic choice of v is

necessary when G is a biconnected comp onent of a larger graph see Section

Lemma Let G b e biconnected and outerplanar and let v denote a vertex in G Let T Y

denote the result of the call to b coptdG v Then T Y is a simple tree decomp osition of

G and T is a spanning tree of G fv g

Pro of We prove using induction on jE Gj a somewhat stronger result We show that T Y

is simple that T spans G fv g and that for each edge ij in G either i V T with fi j g Y

i

or j V T with fi j g Y The lemma holds for the basis case in which G contains just one

j

edge If jE Gj let P with endp oints w and x denote a path that satises Lemma Let

G denote G P fw xg Thus v is in G By the induction hypothesis b coptdG v

returns a simple tree decomp osition T Y with T spanning G fv g and with fw xg Y

w

or fw xg Y Assume without loss of generality that fw xg Y Let T Y denote

x w

the w extensible tree decomp osition of P Then T P fw xg and fw xg Y where a

a

is w s neighbor in P T is formed by adding an edge b etween vertex w in T and vertex a in

T The only vertices common to G and P are w and x which are contained in b oth Y and

w

Y Therefore T Y is a valid tree decomp osition of G T Y is simple b ecause T Y and

a

T Y are simple with the edge w a existing in G T spans G fv g b ecause T spans G fv g

and T spans P fw xg To complete the induction observe that for each edge ij E G

fi j g Y or fi j g Y b ecause either fi j g fw ag Y or fi j g is contained in one of

i j

a

Y Y Y and Y

i j i j

Eciency

We store the input graph in doublylinked adjacency list format This is spaceecient b ecause

outerplanar graphs have a linear number of edges if tw G then jE Gj jV Gj We

also employ a few additional links To facilitate the removal of an edge ab links are maintained

b etween the copy of b in as adjacency list and the copy of a in bs adjacency list The only steps

in b coptd that take more than constant time are i nding a path P that satises Lemma

ii deleting the edges and internal vertices of P from the input graph and iii constructing

an extensible tree decomp osition of P Of these steps ii and iii take at most linear time

over all calls to b coptd Thus the question of eciency reduces to the implementation of

step i One fast metho d is describ ed b elow

Some prepro cessing is required We rst construct an outerplanar layout of G We scan

the layout in a clo ckwise direction starting at v and number vertices in the order in which

they are encountered Then we rearrange the adjacency list of each vertex a so that neighbors

numbered lower than a o ccur b efore neighbors numbered higher than a Each of these tasks

takes only linear time

Once prepro cessing is completed paths to play the role of P are found during a second

clo ckwise scan It follows from Lemma that until G is reduced to a cycle a pair of vertices

may b e the endp oints of P if and only if they are adjacent by an internal edge and all vertices

with numbers b etween them have degree two Vertices of degree three or more are maintained

on a stack As a new vertex is scanned we check whether it is adjacent by an internal edge to

the vertex on top of the stack If it is then we have found P s endp oints If not we push the

new vertex on the stack and continue the scan

It turns out that no vertex will b e pushed on the stack as long as an internal edge makes

it adjacent it to a lowernumbered vertex This in turn implies that G is reduced to a cycle

b efore the scan returns to v Thus the scan terminates after a linear number of steps and

we only need argue that each step can b e accomplished in constant time Let k denote the

vertex b eing scanned and j the vertex on top of the stack We need to check whether j and

k are adjacent by an internal edge Since G is outerplanar and since j cannot b e adjacent to

a lowernumbered vertex by an internal edge either j is adjacent by an internal edge only to

k or k is adjacent by an internal edge to no lowernumbered vertex other than j In the rst

case j has degree at most three In the second j can only b e one of the rst two elements in

k s adjacency list Therefore we need to scan at most ve elements in the adjacency lists of j

and k Thus step i requires only linear time and so do es b coptd

Tackling NonBiconnected Graphs

We now generalize our algorithm to handle all outerplanar graphs

Pro cedure optd

Input An outerplanar graph G of order two or more and sets B and C of its

biconnected comp onents and cut p oints

Output A simple tree decomp osition T Y of G with T spanning G

b egin pro cedure

if G is biconnected

then b egin

u v any two adjacent vertices in G

0 0

T Y b coptdG v

0 0

T T fv g fuv g and Y Y fY g where Y fv g

v v

end

else b egin

B an element of B that contains exactly one vertex v from C

i

if v is not a cut p oint in G B fv g then C C fv g

i

0 0

T Y b coptdB v

i

00 00

T Y optdG B fv g B fB g C

i i

u an arbitrary neighbor of v in B

i

0 00 0 00

T T T fuv g and Y Y Y

end

output T Y

end pro cedure

Lemma Let G b e outerplanar Let T Y denote the result of the call to optdG Then

T Y is a simple spanning tree decomp osition of G

Pro of The pro of pro ceeds by induction on the number of biconnected comp onents of G The

basis case when G is biconnected follows from Lemma and the mo dications made to T Y

after the call to b coptdG v So let B v T Y T Y and u b e as dened in optd

i

Let G denote G B fv g From the pro of of Lemma we know that T Y is simple

i

that it spans B fv g and that fu v g Y there is no Y By the induction hypothesis

i

u v

T Y is a simple spanning tree decomp osition of G Thus by construction T Y is a simple

spanning tree decomp osition of G

Main Result

Biconnected comp onents and cut p oints can b e found using a depthrst search Pro cedure op

td builds an optimal treedecomp osition using b coptd This tree decomp osition is converted

into a path decomp osition using tdp d Recalling Theorem and noting that each of the

aforementioned steps requires only linear time we achieve the following result

Theorem If G is outerplanar a path decomp osition of G with width at most pw G

can b e constructed in linear time

Concluding Remarks

We have implemented our algorithm in the C programming language Tests on a SPARC

ULTRA indicate that the implementation is fast in practice taking for instance less than

two seconds to compute the path decomp osition of a graph with ten thousand vertices It is

dicult to gauge the quality of the solutions pro duced b ecause there is no practical way to

obtain optimal path decomp ositions for comparison As a compromise we tested the program

on pseudorandom outerplanar graphs of known pathwidth These tests indicate that the

approximate decomp ositions tend to have much smaller width than the worst case guarantee

Our work has exploited the fact that if the width of a tree decomp osition T Y of G

is b ounded and if pw T is within some constant multiple of pw G then we can construct a

path decomp osition of G whose width is at most a constant times pw G Seriesparallel graphs

also have treewidth at most two Optimal tree decomp ositions for them can b e constructed

quickly We b elieve that for these graphs it is p ossible to ensure pw T pw G yielding a

factorofsix relative approximation algorithm

On a more general note we conjecture that any graph G has an optimal tree decomp osition

T Y such that pw T pw G If true a constructive pro of of this would provide a relative

approximation algorithm for any class of graphs whose b oundedwidth tree decomp ositions can

b e found eciently Currently this class includes all graphs of treewidth four or less and for

any xed k k chordal graphs k outerplanar graphs and graphs with disk dimension k to name

just a few

References

H L Bo dlaender and T Kloks Ecient and Constructive Algorithms for the Pathwidth

and Treewidth of Graphs Journal of Algorithms

N Deo M S Krishnamo orthy and M A Langston Exact and Approximate Solutions

for the Gate Matrix Layout Problem IEEE Transactions on ComputerAided Design

J A Ellis I H Sudb orough and J S Turner The Vertex Separation and Search

Number of a Graph Information and Computation August

M R Fellows and M A Langston On WellPartialOrder Theory and Its Application

to Combinatorial Problems of VLSI Design SIAM Journal on Discrete Mathematics

A Kornai and Z Tuza Narrowness pathwidth and their application in natural lan

guage pro cessing Discrete Applied Mathematics

N Rob ertson and P D Seymour Graph Minors I I Algorithmic Asp ects of Treewidth

Journal of Algorithms

X Yan A Relative Approximation Algorithm for Computing Pathwidth Masters

Thesis Department of Computer Science Washington State University Pullman WA