• Nenhum resultado encontrado

The goal is to nd a tree whih minimizes the sum of its edge osts and the penalties for the verties left out of the tree

N/A
N/A
Protected

Academic year: 2022

Share "The goal is to nd a tree whih minimizes the sum of its edge osts and the penalties for the verties left out of the tree"

Copied!
7
0
0

Texto

(1)

O(n logn) implementation of an approximation

for the Prize-Colleting Steiner Tree Problem

PauloFeolo

CristinaG.Fernandes y

CarlosE. Ferreira z

JoséCoelhodePina

February 2002

Abstrat

We give alow-leveldesriptionof an O(n 2

logn)implementation of Johnson,Minko and

Phillips'approximationalgorithmforthePrize-ColletingSteinerTreeProblem.

1 Introdution

ThePrize-Colleting SteinerTree Problemis anextension of theSteinerTree Problemwhere eah

vertex left out of the tree pays a penalty. The goal is to nd a tree whih minimizes the sum

of its edge osts and the penalties for the verties left out of the tree. Johnson, Minko and

Phillips [2 ℄ presenteda 2-approximation for the this problembasedon the primal-dualsheme. In

this manusript, we desribe indetailsan O(n 2

logn)implementation of this algorithm.

Weadoptthenotationused[1 ℄,whihissummarizedbelow. Westartwithaformaldenitionofthe

problem. Consider a graphG=(V;E), afuntion from E into Q

(non-negative rationals) and

afuntion fromV into Q

. For anysubset F ofE andanysubset W of V,let(F) :=

P

e2F

e

and (W) :=

P

w2W

w

. The Prize-Colleting Steiner Tree Problem(pst) onsists of the

following: given G,,and ,nda treeT inGsuh that

(E

T

)+(V nV

T

) isminimum:

(V

H

and E

H

denotethe vertexand edgesets ofa graph H.)

An edge is internal to a partition P of V if both of its ends are in the same element of P. All

other edges areexternal to P. For anyexternal edge, there aretwo elements of P ontaining its

ends. Weall these two elementstheextremes of theedgeinP.

AolletionLofsubsetsofV islaminarif,foranytwoelementsL

1 andL

2

ofL,eitherL

1

\L

2

=;

orL

1 L

2 orL

1 L

2

. TheolletionofmaximalelementsofalaminarolletionLwillbedenoted

by L

. So,L

isa olletionofdisjointsubsets ofV. Let S

Ldenote theunionof allsets inL.

DepartamentodeCiêniadaComputação,InstitutodeMatemátiaeEstatístia,UniversidadedeSãoPaulo,Rua

doMatão1010,05508-090 SãoPaulo/SP,Brazil. E-mail: {pf,ris,ef,oelho}ime.usp. br. Researhsupported

inpartbyPRONEX/CNPq664107/1997-4(Brazil).

y

ResearhsupportedinpartbyCNPqPro.301174/97-0(Brazil).

z

ResearhsupportedinpartbyCNPqPro.300752/94-6(Brazil).

(2)

ForanyolletionLofsubsetsofV andanysubsetX ofV,letX:=VnX,L :=fL2L:LXg

and L

X

:=fL 2L:LXg. When X =fvg, we write L v

and L

v

instead, andwhen X =V

T or

X=V

T

,wewriteT orT instead. ForanyeinE,letL(e):=fL2L:e2Æ

G

Lg;where Æ

G

Lstands

for thesetofedges ofG withone end inLand the otherinL. For anyfuntion y fromL into Q

and anysubolletion MofL,let y(M):=

P

L2M y(L).

We saythaty respets afuntion dened onE (relative to L)if

y(L(e))

e

for eaheinE. (1)

An edgeeistight for y ifequalityholds in(1).

We sayy respets afuntion dened on V (relative to L)if

y(L L

) (L) for eah L inL. (2)

(3)

2 Johnson, Minko and Phillips' algorithm

In itshigh-level desriptionbelow, we refer to analgorithm Pruning whose high-leveldesription

we omit. It orresponds to the seond phase of the primal-dual sheme, where edges are deleted

fromthetree produed inthe rst phase.

Johnson, Minko and Phillips' algorithm reeives G, , and returns a tree T in G suh that

(E

T

) +(V

T

) 2opt (pst (G;;)): Eah iteration starts with a spanning forest F in G, a

laminar olletion L of subsets ofV with S

L =V,a subolletion S of L, and afuntion y from

L into Q

. The rstiteration startswith F =(V;;), L=ffvg:v2Vg, S =;, and y =0. Eah

iteration onsistsof thefollowing:

Case 1: jL

nSj>1.

Let"bethe largest numberinQ

suhthatthe funtion y 0

dened by

y 0

L

=

y

L

+"; ifL2L

nS

y

L

; otherwise

respets and.

Subase 1A:some edgeeexternal to L

istight for y 0

.

Let L

1 and L

2

be the extremes of e in L

. Set y 0

L

1 [L

2

:= 0 and start a new

iterationwithF+e,L[fL

1 [L

2 g,S,y

0

intherolesofF,L,S,yrespetively.

Subase 1B:some element L ofL

nS istight fory 0

.

Start a new iteration with F, L, S [fLg, y 0

in the roles of F, L, S, y

respetively.

Case 2: jL

nSj=1.

Let M be the only element of L

nS. Call subalgorithm Pruning with arguments

F \M, L M

, and S M

. The subalgorithm returns a subolletion Z of S M

. Return

T :=(F \M) S

Z and stop.

(3)

Hereis thelistof variables and funtionsusedbythe algorithm:

1. L

1

;:::;L

N

arenonemptysubsetsofV

G

suhthatL

1

[[L

N

=V

G

and,foreahpairi<j,

eitherL

i L

j or L

i

\L

j

=;,whene N <2n,where n:=jV

G

j. Eah L

i

is representedbya

bit vetor aswell asbya linked list. (In thehigh-level version of thealgorithm given in[1 ℄,

fL

1

;:::;L

N

g isdenotedbyL.)

2. Asubset F of E

G

,represented asa doubly-linked list(abit vetorwould be toolong). Sine

(V

G

;F) is aforest, jFj<n.

3. A bitvetor [1::N℄ suhthat [i℄=1 i L

i

is amaximal element offL

1

;:::;L

N

g. (Inthe

high-levelversionof thealgorithm, thisset ofmaximal elementsis denotedby L

.)

4. An array d indexed by V

G

with values in Q

. (In terms of the high-level notation, d[v℄ :=

L

v

P

L2L:v2L y

L

for eah vertexv.)

5. AfuntionResidualCostthattakesedgesintoQ

: uponreeivinganedgeuv,thefuntion

returns the number

uv

d[u℄ d[v℄. Of ourse this an be implemented to run in O(1)

time. (We do not treat ResidualCost as an array beause we annot aord to update

ResidualCost every timed hanges.)

6. An array [1::N℄ with values in Q

.

1

(In terms of the high-level notation, [i℄ =

P

v2L

i [v℄

P

SL

i y

S .)

7. Abitvetor [1::N℄suh thatif[i℄=0 then[i℄=0. WesaythatL

i

isative i[i℄=1.

(Interms ofthe high-level notation,[i℄=0 iL

i 2S.)

8. Avariable mxAtive reordstheardinalityof thesetfi:1iN;[i℄=1;[i℄=1g.

9. AnarrayA[1::N;1::N℄whoseelementsaresetsof atmostone edgeeah. Morespeially,

for i6=j suhthat(i)=(j)=1,

ifÆ(L

i

)\Æ(L

j

)=; thenA[i;j℄=A[j;i℄=;;

otherwise, A[i;j℄ = A[j;i℄ = fuvg where uv is an element of Æ(L

i

)\ Æ(L

j ) that

minimizes ResidualCost (uv).

10. AfuntionKeydened onf1;:::;Ngf1;:::;Ngasfollows: ifA[i;j℄=;thenKey(i;j)=

1; else Key(i;j) =ResidualCost(uv), where uv is the unique edge in A[i;j℄. Of ourse

this funtionan beimplemented to runinO(1) time.

11. For eahisuhthat[i℄=1,therearetwosubsetsof f1;:::;Ng denotedbyH

0

[i℄andH

1 [i℄.

For eah h,the setH

h

[i℄onsistsof allj 6=isuh that

[j℄=1; [j℄=h; A[i;j℄6=;:

EahsetH

h

[i℄isorganizedasamin-heap, thekeyofeahelement jbeingKey (i;j).

2

Hene,

therstelement ofH

h

[i℄minimizes Key(i;).

1

Johnson,MinkoandPhillipssaythisisthesurplusofLi.

2

Johnson,MinkoandPhillipssaythatthekeyofjisthedeit oftheonlyedgeinA[i;j℄.

(4)

p2H

h

[i℄ istrueor false. Moreover, ifthestatement istrue,we assumethatthedeletionof

pfromH

h

[i℄ande arriedoutinO(logn) time. (Thisiseasy toimplement: foreahi, eah

h,and eah pinf1;:::;Ng,maintaintheloation of pinH

h [i℄.)

4 Main funtions

Theore ofthe algorithm is givenbythenext funtions.

PCST-low-level (G;;)

1 Iniialization()

2 N mxAtive n

3 while mxAtive >1 do at most 2niterations

4 OneIteration()

5 (X;F) Pruning ()

6 return X and F

The number of iterations is 2n beause the sum 2mxAtive +mxInative,where mxInative

istheardinality of fi:1iN;[i℄ =1;[i℄=0g,starts at 2nand stritly dereases witheah

iteration.

Iniialization()

01 n jV

G j

02 i 0

03 for eahv inV

G do

04 d[v℄ 0

05 i i+1

06 L

i

fvg

07 o[v℄ i

08 [i℄ [i℄ 1

09 [i℄

v

10 for eahiinf2;:::;ngdo

11 for eahj inf1;:::;i 1g do

12 A[i;j℄ ;

13 Key(i;j)=1

14 for eahiinf2;:::;ngdo

15 for eahuv inÆ(L

i ) do

16 ifo[u℄=i

17 thenj o[v℄

18 else j o[u℄

19 ifKey(i;j)>ResidualCost(uv)

20 thenA[i;j℄ A[j;i℄ fuvg

(5)

22 H

0 [i℄ ;

23 for eahiinf1;:::;ngdo

24 H

1 [i℄ ;

25 for eahj inf1;:::;ng figdo

26 ifA[i;j℄6=;thenH

1

[i℄ H

1

[i℄[fjg

The total time spent exeuting lines 1420 is O(m) = O(n 2

). The total time spent building the

heap H

1

[i℄inlines2021isO(n). Thetotal spentbyIniialization is O(n 2

).

OneIteration() eah all takes O(nlogn) time

01 "

0

"

00

1

02 for eahp inf1;:::;Ng suh that[p℄=[p℄=1do

03 if"

0

>[p℄

04 then"

0

[p℄

05 p

0

p

06 ifH

0 [p℄6=;

07 then let q be the rst element ofH

0 [p℄

08 if"

00

>Key (p;q)

09 then"

00

Key (p;q)

10 p

00

p

11 q

00

q

12 ifH

1 [p℄6=;

13 thenlet q be therst element ofH

1 [p℄

14 if"

00

>

1

2

Key(p;q)

15 then"

00 1

2

Key (p;q)

16 p

00

p

17 q

00

q

18 " min("

0

;"

00

)

19 for eahp inf1;:::;Ng suh that[p℄=[p℄=1do

20 [p℄ [p℄ "

21 for eahv inL

p do

22 d[v℄ d[v℄+"

23 no need to rebuildheapsH

0

and H

1

24 if"="

0

25 thenSubCase1B(p 0

) takestimeO(nlogn)

26 else SubCase1A (p 00

;q 00

) takestime O(nlogn)

Taken together,allexeutionsofline 22onsume O(n)time. Thetotal spentbyOneIteration is

O(nlogn).

(6)

p q

01 letuv be the unique element ofA[p;q℄

02 F F [fuvg

03 L

N+1 L

p [L

q

04 [p℄ [q℄ 0 L

p and L

q

are nolonger maximal

05 [N+1℄ 1 nowL

N+1

ismaximal

06 if[q℄=1 thenmxAtive mxAtive 1

07 [N+1℄ [p℄+[q℄

08 [N+1℄ 1 now L

N+1

isative

09 for eahiinf1;:::;Ng suhthat[i℄ =1do

10 ifKey(p;i)Key(q;i)

11 thenA[N+1;i℄ A[i;N +1℄ A[p;i℄

12 else A[N+1;i℄ A[i;N +1℄ A[q;i℄

13 for eahh inf0;1g do

14 H

h

[N +1℄ H

h

[p℄ time O(1)

15 H

h

[N +1℄ H

h

[N+1℄ fqg time O(logn)

16 for eahiinH

h [q℄do

17 ifi2= H

h

[N+1℄

18 thenH

h

[N+1℄ H

h

[N+1℄[fig time O(logn)

19 ifi2H

h

[N+1℄andKey (N+1;i)>Key(q;i)

20 thenDerease-Key(H

h

[N+1℄;i;Key(q;i))

21 for eahiinf1;:::;Ng suhthat[i℄ =1do

22 H

0

[i℄ H

0

[i℄ fqg time O(logn)

23 H

1

[i℄ H

1

[i℄ fp;qg timeO(logn)

24 ifKey(i;N +1)<1

25 thenH

1

[i℄ H

1

[i℄[fN+1g timeO(logn)

26 N N +1

SubCase1B(p) deativateL

p

01 [p℄ 0

02 mxAtive mxAtive 1

03 for eahiinf1;:::;Ng fpg do

04 ifp2H

1 [i℄

05 thenH

1

[i℄ H

1

[i℄ fpg timeO(logn)

06 H

0

[i℄ H

0

[i℄[fpg time O(logn)

(7)

Pruning() O(n ) time

01 for i N downto 1do reverse delete

02 if[i℄=0 L

i

is inative

03 thendegree 0

04 for eah uv inF do O(n)time

05 ifjfu;vg\L

i

j=1 O(1)time

06 then degree degree+1

07 degreee is theardinalityof F \Æ(L

i )

08 ifdegree 1

09 thenfor eah uv inF do

10 ifjfu;vg\L

i j1

11 thenF F fuvg

12 ifF 6=;

13 thenletX be the setof verties ofG[F℄

14 else letx be a vertexthatmaximizes

x

15 X fxg

16 return(X;F)

Referenes

[1℄ P. Feolo, C.G. Fernandes, C.E. Ferreira, and J. de Pina. Approximation algorithms for

the prize-olleting Steiner tree problem. Available at http://www.ime.usp.br/ris/publ/.

Submitted, 2004.

[2℄ D.S. Johnson, M. Minko, and S. Phillips. The prize olleting Steiner tree problem: theory

and pratie. InSymposium on Disrete Algorithms,pages 760769, 2000.

Referências

Documentos relacionados

A infestação da praga foi medida mediante a contagem de castanhas com orificio de saída do adulto, aberto pela larva no final do seu desenvolvimento, na parte distal da castanha,

i) A condutividade da matriz vítrea diminui com o aumento do tempo de tratamento térmico (Fig.. 241 pequena quantidade de cristais existentes na amostra já provoca um efeito

Due to the lack of studies in the literature related to the best method of propagation for the crop, a number of studies were carried out to verify the possibility of

didático e resolva as ​listas de exercícios (disponíveis no ​Classroom​) referentes às obras de Carlos Drummond de Andrade, João Guimarães Rosa, Machado de Assis,

Otros, como Abatecola (2014), por ejemplo, exponen las fronteras de estudio y prospección, dejando de lado el bagaje de la teoría evolutiva en otras áreas o disciplinas de

Immobilization has long been used to improve enzyme activity and stability in aqueous media, and, more recently, also in nonaqueous media (Bickerstaff, 1997; Bornscheuer, 2003),

In this case, the cohesive failure was characterized by an initiation zone where the failure looks similar to the fracture zones obtained for Mode II followed by

The probability of attending school four our group of interest in this region increased by 6.5 percentage points after the expansion of the Bolsa Família program in 2007 and