A Dynamic Programming Framework for Combinatorial Optimization Problems on Graphs with Bounded Pathwidth

In this paper we present an algorithmic framework for solving a class of combinatorial optimization problems on graphs with bounded pathwidth. The problems are NP-hard in general, but solvable in linear time on this type of graphs. The problems are r…

Authors: Mugurel Ionut Andreica

A Dynamic Programming Framework for Combinatorial Optimization Problems on Graphs with Bounded Pathwidth Mugurel Ionut And reica 1 1 Polytechnic Universit y of Bucharest, mugurel .andreica @cs.pub.ro Abstract -In this paper w e present an algorithmic framework for solving a class of co mb inatoria l optim ization problems on graphs with bounded pathwidth. The p roblems are NP-hard in general, but so lvable in li near tim e on this type of graph s . The problems are relevant for assessing netw ork reliability and i mproving the network’s performance and fault tolerance. The ma in technique co nsidered in this paper is dynamic programming. I. I NTRODUCTI ON Network reliability analysis and the improve ment of the network ’s perfor mance and fault tolerance are issues of great interest to t he net working co mmunity. Careful net work a nal y- sis and te sting, based on rele vant reliabilit y metrics, can point out net w or k v ulnerabilities which could severel y impact ne t- work performance, while improving the network’s fault tol e r- ance can h elp eliminate so me of these proble ms. The net work can be modeled as an undirected graph, with network node s as vertices and network li nks as ed ges. The vertice s and ed ges may have several par ameters asso ciated to them, like cost, r a- dius (in the case of w ireless networks), late ncy, bandwidth and many other s. We believe that some of the prop erties o f the co r- responding graph model ca n be used i n o rder to define effe c- tive network reliability metrics and for improving the ne t- work’s p erformance level and d egree of fault tolerance . In this paper, we present efficient al gorithms for computing some i m- portant prop erties and solving combinatorial opti mization pro b- lems for the class of graphs with bounded path width. We focus here only on t he algorithms, w hose ef ficiency is i mportant e s- pecially i n th e case o f lar ge grap hs (like th ose encountered in practical sit uations), and leav e other aspect s for future work. All t hese algorithms are p resented as part of a generic fra m e- work, which can be further extended with algorithms not c o n- sidered in this paper. The rest of the pap er is structured as fo l- lows. In Section II we pr esent formal definitions of the co n- cepts used in t he rest of t he paper. In Section III we present a generic d ynamic p rogramming frame work for solving comb i- natorial o ptimization pro blems o n gr aphs with b ounded p at h- width. In Sect ion IV we p resent se veral clear e xamples regar d- ing the usage o f the framewor k and in Section V we present re lated w ork. Finall y, in Secti on VI we conclude and mentio n directions for future resear ch. II. G RAPHS WITH B OUN DED P ATHWIDTH The pathw idth of an undirected graph is a number w hich r e- flects t he resemblance o f t he graph’s structure to a path – th e lower the pathwidth, the c loser the grap h “looks” like a p ath. A path decomposition of a graph G is a path D, with nodes D 1 , D 2 , ..., D P (in the order they li e on the path), having t he foll o w- ing properties:  each node D i correspo nds to a subset of nv(i) ≥ 0 vertices of G (we will denote the subset by D i , too)  any two adjacent vertices of the graph G, u and v, b e- long together to at least one subset D i  each vertex u of G belo ngs to at least one subset D i a nd if u belongs to two subsets D i and D k , then it also b e- longs to a ll t he s ubsets in between D i a nd D k ( the s u b- sets which contain a verte x u form a sub -path of D) The width of the path d eco mposition is defined a s pw D =max{nv(1 ) , …, nv(P) } -1. The m inimum value o f pw D of a path dec omposition of the graph is called the graph’s p at h- width . Finding a path deco mposition with minimum width is an NP -hard prob lem, but i n many p ractical situations, a d ecomp o- sition whose width is bounded by a constant can be easily found. Moreover, some ef ficient algorith ms for finding path decompositions of s mall width have bee n developed [ 4 ]. The p athwidth concept is stro ngly related to the notio n of treewidth, which was i ntroduced b y Robertso n a nd Se ymour [1]. The treewidth captures t he degree of similarity o f a gra ph’s structure to a tree. Many NP-hard proble m s can be solved in polynomial time on grap hs whose path width (or treewidth) are bounded by a constant . The se algorithms are usually based o n the d ynamic programming technique and ha ve a time co mple x- ity of the form O(f(pw)·n), where f(pw) is a function which is exponential in the width of the path dec omposition pw , a nd n is the number of vertices of the graph. The algorithms make use of a path dec omposition of t he g raph. In order to simplify the algorithms, we will introd uce the concept of nice pat h deco m- positions. The nodes (subsets) of a nice path dec ompositio n are of the following two types :  Introduce node : If D i is an introd uce node, then } { 1 x D D i i    , where x is a vertex which does not b e- long to D i-1 (the introduced ver tex). D 1 is an introduce node consisting of just o ne vertex.  Forget node : If D i is a forget node, then } { \ 1 x D D i i   , where x is a vertex which belo ngs to D i-1 , but not to D i (the forgotten vertex). D P is a forget node with nv(P)=0. Any p ath decomposition can be easily tran sformed in to a nice path deco mposition with O(n) nodes in O(n) time [5 ]. All the algorit hms in the subseq uent section will consider that a nice path deco mposition is already known. III. A D YNAMIC P ROGRAMMING F RAMEWORK Dynamic pro gramming algorith ms traverse t he nodes o f the given nice p ath deco mposition in order and for ea ch nod e i they co mpute a table T i . The size of the table T i is exponential in the number of vertices of the s ubset D i . Each entry o f the table contains a state S a nd a value v, i.e. T i [S]=v. S is the state of the vertices in D i and is usually co mposed of one or several values for each vertex in D i . v is the value of the optimiza tion function, restricted to the verti ces in  i j j i D UD 1   and considering t hat the verti ces in D i are in state S. T i [S] is computed based on the values T i-1 [S’ ], f or some states S ’ which are compatible with t he state S. The definition of state com p a- tibility depends on the actual p roblem solved (just like the d e- finition of the state itself). Eac h state ob eys several structural rules, which depend on t he problem . W e will call the st ates which violate so me o f the se rules intermediate states. These states will need to be n ormalized into valid states. The set of all valid states of a node D i is called VS i . Within the proposed generic algorithm, we will iterate through all the states for node D i-1 and expand these state s into valid states for the node D i . The expansion function will d e- pend on the actions that we can perform (which are problem dependent) and on node D i ’s type (Introd uce or For get node). In th e end, the solution will be found in o ne o f the en tries of the table T P , considering only states belo nging to a subset o f valid final states . We are only interested in findi ng the value of an opti mization functio n, not the states of t he graph vertices leading to the optimal value. However, these states can easil y be computed f ro m the tables stored for each n ode of the p ath decomposition (b y goin g back fro m node P to nod e 1 ) . T he generic dynamic progra mming algorithm is given belo w: Generic Dynamic Pro gramming Algorith m: compute T 1 [S], for all states S in VS 1 for i=1 to P-1 do for all states S in VS i+1 do T i+1 [S]=uninitialized for S in VS i , such that T i [S ] ≠ uninitialized do for action in setOfActions(i+1) do // S’ is an interm ediate state (not necessarily valid) // C is the (new ) value of the optimization function ( S’ ,C ,ok)= expandState ( S , i, action ) if ( ok=true ) then S’’= norm alize ( S’ ) if (( better ( C, T i+1 [S’’] )) or ( T i+1 [S’’]=unintialized )) then T i+1 [S’’]=C OPT=uninitialized for S in setOfValidFinalStates () do if ( better ( T P [S], OPT )) or ( OPT=uninitialized ) then OPT=T P [S] return OPT From a n i mplementation point of view, the states for each node will be generated in an array of states, w hich can b e tr a- versed easil y. When reading or w riting a value T i [S], we need to know the index of state S in the arra y of states (b etween 1 and the total number of states). The most efficient way to do this is to u se two hash functi ons (hash 1 and hash 2 ). h as h 1 w ill generate a u nique hash val ue for each state S (no collis ions are allowed). This value will b e stored in a ha sh tab le, together with the state index. The hash table w ill use the ha sh 2 fu nction and permits some collisions. T he pseudocode below illustrates the use of this approac h. generateStat es(i): // generates all the states for node D i stateIndex=0 for each state S generated do h 1 = hash 1 ( S ) stateIndex=stateIndex+1 hashTable[i].put(S, stateIndex) // hashTable[i] uses hash 2 () getStateIndex(S, i) return hashTable[i].get( hash 1 (S)) Since we are discussing efficiency, we should n ote that the sets of states of two nodes D i and D j will differ only if nv(i) ≠ nv(j). T his sugg ests that we could generate the states only for ea ch disti nct value o f the number of vertices (there are only pw D +1 such val ues) and not for each node. IV . C OMBI NATORIAL O PTI MIZATION P ROBLEMS In this section we will present sev eral combinatorial optim i- zation proble ms which can be solved using the generic fra m e- work presented in the previous section. The problems have practical applications to netwo rk reliabilit y anal ysis and fault tolerance and per formance impro vement. A. Coloring a graph with a fixed n umber of colors We are given a graph G together w ith a nice path dec omp o- sition of t he graph. We have to assign to each vertex of the graph a color from the set {1,2,…,C}, such tha t an y two verti c- es connected by an edge ar e assigned different color s. This is one of the si mplest pr oblems, in which the functio n which need s to be computed is a binary function. We need to decide if a coloring exists or not. If it exists, th e verte x colors can be d erived from the tables stored at each node o f the path decomposition. Furthermore, we can use the solution to t his problem in a b inary (or line ar) search algorithm, in ord er to find the minimum number of colors required to color the graph . The state o f the vertices of a node D i of the path dec ompos i- tion has the for m S=(c 1 , c 2 , …, c nv(i) ), where } ,. .. , 1 { C c i  is the color of the i th vertex in the su bset D i . We will, occasionally, denote by S[i] t he i th component of the state S. We will consi d- er the vertice s o f a node D i ordered as v i,1 , v i,2 , …, v i,nv(i) . If D i is a n Introd uce nod e, then we will consider that the introd uced vertex is v i, nv(i) . We w ill maintain t hese vertex ordering a s- sumptions in all the other problems consider ed in this secti on. An entr y T i [S] has one o f the values true or unin itialized , meaning that t here exists (do es not exist) a co loring of the ve r- tices in UD i , such that the vertices in D i are colored accord ing to the state S. Node D 1 contains only a single verte x, so we will assign T 1 [S]=true, for all the states S i n VS 1 . The set of actio ns which can be per formed for expanding a state S of th e node i into a state S ’ of the nod e i+1 depends o n the type of the node D i+1 . If D i+1 is an Introd uce node, the set of actions consists of coloring t he i ntroduced nod e in every p ossibl e color; if it is a Forg et node, only a “forget” action exists. We w ill now de fine all the fu nctions required to turn t he ge neric algorit hm fr om Se ction II into a solution to the p roblem. setOfActions(i) : if ( D i is an Introduce node ) then return { (Col, 1) , (Col, 2) , …, (Col, C) } else return { Forget } updateCost(S, i, C): // auxiliary function, used by expandState let S=(c 1 , c 2 , …, c nv(i) ) for j=1 to nv(i)- 1 do if (( v i,j and v i,nv(i) are adjacent ) and ( c j =c nv(i) )) then return ( () , 0, false ) return ( S, 1, true ) expandState(S, i, action): if ( D i is an Introduce node ) then (Col, cx)=action // cx is the color assigned to the new vertex S’=(c 1 , c 2 , … , c nv(i)-1 , c nv(i) = cx ) , where S=(c 1 , c 2 , … , c nv(i)-1 ) return updateCost ( S ’, i, T i-1 [S] ) else v i-1,j = the “forgotten” node S’=(c 1 , c 2 , …, c j-1 , c j+1 , …, c nv(i-1) ) , where S=(c 1 , c 2 ,…, c nv(i-1) ) return ( S’ ,1,true ) normalize(S): return S better(cost 1 , cost 2 ): if ( cost 1 =1 ) then return true else return false setOfValidFinalStates(): return VS P // all the states of D P are valid final states It is obvious that the expand State function is the most impo r- tant one in the algorithm and this will b e the case with each problem we will consider. In th is function, the selected action is performed and the validity of the resulting inter mediate state is checked. T he co m plexit y of the algorithm is O((pw+1)·C pw+1 ·P), considering t hat the path deco mposition has width pw. Since P is O(n) and (pw+1)·C pw+1 is bounded by a constant, the time co mplexity of the algorit hm is linear. B . Colo ring a graph with a fixed nu mber of colors – improved state definition The improvement of the previo us solution consists i n redu c- ing t he number of states. It is o bvious that, given a valid colo r- ing of t he grap h’s vertice s, we can relab el the colors d ifferently and still get a valid coloring. For instance, if C=3 a nd w e have two vertices a and b colored with colors 3 and 2 , respectively, we ca n relabel the co lors such that vertex a is colored w ith 1 and vertex b is colo red with 2. This suggests that the colors o f a state S should form a partition and obey the following rules:  c 1 =1  } 1 ,. . . , 1 { 1    i i m c , where } { m a x 1 1 1 j i j i c m      With t hese r ules, t he state S’ returned b y the expand State function may not be a valid state. Therefore, we will have to define the normalize function differently: normalize(S): S’=S, where S=(c 1 , …, c K ) counter=0 newlabel={0,0,…,0} // K zeroes for i=1 to K do if (newlabel[S[ i]] =0) then counter=counter+1 newlabel[ S[i]]=counter S’[i ] =newlabel[S[i ]] return S’ The n ormalize function relabels the color s of a state S suc h that they o bey the structural rule. The number of state s is grea t- ly reduced. Fo r instance, for C=7 and a node D i w ith nv(i)=9 , the number of states is equal to the number of partition s of a se t with 9 ele ments into at m ost 7 par ts, which is 21 , 110 . Before, the number of states was 9 7 = 4, 782 , 969 . C . Coloring a grap h with a fixed n umber of co lors in o rder to minimize penalties d ue to co loring conflicts This problem is similar to the previous one, except that a v a- lid co loring is not necessarily required. Each graph edge ( u,v) has a n associated p enalty value p en (u,v) . If the vertices u and v are ass igned the s ame color, then the penalt y p en (u,v) will be paid. T he optimization function consi sts of minimizing t he sum of p aid penalties. For this proble m, we will keep the sa me s tate definition as in the prev ious case, the same sets of actio ns and the same va lid final sta tes. We will have to slightly modify the expandState f unction, by redefining t he auxiliary functio n u p- dateCost , and the better functio n. T i [S] no w represents the mi nimum pe nalty paid su ch t hat all vertices in UD i are co lored and the v ertices in D i are colored according to the state S. T 1 will be initialized with 0 for every possible state. updateCost(S, i, C): C ’=C for j=1 to nv(i)- 1 do if (( adjacent (v i,j ,v i,nv(i) ) ) and ( S[j]=S[nv(i) ] )) then C ’= C ’ +p en (v i,j , v i,nv(i) ) return ( S,C ’ ,tru e ) better(cost 1 , cost 2 ): if ( cost 1 it lies in side a path)  s j >0 implies that v i,j has degre e 1 in the path co ver and is one of two endpoints o f a path; s j is the path’s identifier If s j >0, th ere can be at most one other vertex v i,k with s k =s j (the other endpoint of the same path). It is also possible that the other endpoint d oes not belo ng to D i ( it w as “left behin d”). In this proble m, T i [S] represents t he minimum n umber of paths which cover all t he vertices in UD i , considering t hat the verti c- es in D i are in state S. T he o nly valid state for D 1 is S=(-1), with T 1 [S]=1. We w ill define next all t he functions required by the generic dynamic pr ogramming algorithm. setOfActions(i) : if ( D i is an Introduce node ) then actionSet={ newPath } for j=1 to nv(i)-1 do if ( adjacent (v i,j ,v i,nv(i) ) ) then )} ath, v { ( e x te ndP actionSe t actionSe t i,j   for j=1 to nv(i)-2 do for k=j+1 to nv(i)-1 do if ( adjacent(v i,j , v i,nv(i) ) and adjacent(v i,k , v i,nv(i) ) ) then )} ,v Paths, v { ( c onnec t actionSe t actionSe t i,k i,j   return actionSet else return { Forget } expandState(S, i, action) : let S=(s 1 , s 2 , …, s nv(i)-1 ) if ( D i is an Introduce node ) then if ( action=newPath ) then S’=(s 1 , …, s nv(i)-1 , - 1) return (S’, T i-1 [S]+1, true) else if (action=(extendPath, v i,j )) then if ( s j =0 ) then return ( (), +Infinity, false) else if ( s j >0 ) then S’=(s 1 , …, s j-1 , 0, s j+1 , …, s nv(i)-1 , s j ) return ( S’,T i-1 [S], true ) else // s j =-1 pid=max{0, s 1 , s 2, …, s nv(i)-1 }+ 1 S’=(s 1 , …, s j-1 , pid, s j+1 , …, s nv(i)-1 , pid) return (S’, T i-1 [S], true) else let action=(c onnectPaths, v i,j , v i,k ) if (( s j =-1 ) and ( s k =-1 )) then pid=max{0, s 1 , s 2, …, s nv(i)-1 }+1 S’=(s 1 , …, s j-1 , pid, s j+1 , …, s k-1 , pid, s k+1 , …, s nv(i)-1 , 0) return ( S’,T i-1 [S]-1, true ) else if (( s j =-1 ) and ( s k >0 )) then S’=(s 1 , …, s j-1 , s k , s j+1 , …, s k-1 , 0, s k+1 , …, s nv(i)-1 , 0) return ( S’,T i-1 [S]-1, true ) // the case (s j >0) and (s k =-1) is treated in a similar m anner else if (( s j >0 ) and ( s k >0 ) and ( s j ≠ s k )) then S’ =(s 1 , …, s nv(i)-1 , 0) // relabel the other endpoint of one of the two paths find k’ such that s k’ =s k if ( k’ exists ) then S’[k’ ]=s j S’[j]=S’[k]=0 return ( S’,T i-1 [S]-1, true ) else // we tried to connect the endpoints of the same path return ( (), +Infinity, false ) else v i-1,j = the “forgotten” node S’= (s 1 , s 2 , …, s j-1 , s j+1 , …, s nv(i-1) ) return ( S’, T i-1 [S],true ) The normalize function is almost t he same as for the pr e- vious problem, except that all th e values s j equal to -1 or 0 are left unchanged. On ly t he path ids are relabeled, such that the y form a partition into classes in which every class contains at most t wo vertices. T he better and setOfValidStates f unctions are also maintained. T he ti me complexity of t he algorit hm is O(pw 3 ·max{|VS i |}·n), where |VS i | is exponential in pw. E . Minimum Cycle Cover A minimum cycle cover has a definition which is almost identical to th e m inimum p ath cover, except th at it consists of cycles, i.e. paths in which the first and last vertex must also be connected by a n ed ge (t his e xcludes paths co mposed of only one or two vertices). There are some m inor adjustments which need to be made. First, T i [S] will represent the min imu m nu m- ber of closed cycles which co ver all the vertices i n UD i and the state of the v ertice s in D i is S. Furthermore, all the vertices in UD i \D i b elong to an o pen or closed cycle. B oth endpoints of the open cycles (i.e. paths) mu st belong to D i (excep t when the open c ycle contains o nly on e vertex) . This cha nges the state definition slightl y, i n the se nse that if S=( s 1 , …, s nv(i) ) is the state of the vertices of the n ode D i and s j >0 for a vertex v i,j , there must e xist a vertex v i,k with s k =s j . T he set o f valid final states co ntains only one state S fin al =(0, 0, …, 0), i.e. when t here are no open c ycles left. The set o f actions for an Int roduce node is extended in order to contain actions of type (clos e- Cycle, v i,j , v i,k ) , w here v i,j and v i,k must b e the two endpoints of an open cycle. T he cost value returned b y the expandState function i s always T i-1 [S], exc ept when an open cycle is closed , in which case the cost will be T i-1 [S]+1. If D i is a Forget node in t he ex pandState function, the al gorithm must first verify that the state of the “forgotten” node v i-1,j in S is S[j]=0 (i.e. it is not the e ndpoint of a n o pen c ycle). If S[j ] ≠ 0 t he ret urned tuple will be ( () , +Infinity, false ). For lack o f space, the d escribed changes will not be presented in pse udocode . We draw atte n- tion to the fact t he Mini mum Cycle Cover contains the Hami l- to nian Cycle as a p articular case and it is NP -hard in general. F . k-Replica Placement We are given an undirec ted grap h with n vertices togethe r with a nice path decompositio n w ith small pathwidth pw. We want to select k distinct vertic es of the graph and place a repl i- ca of some p opular con tent in them. The cost o f selecti ng a vertex i is csel(i) . If two verti ces u and v which are adj acent to one another are selected , th en we will also need to pay a p ena l- ty cost pen(u,v) . We are i nterested in paying the minimum t otal cost for placing the k replicas . The state d efinition w e will use is the following: f or a node D i , a state S has t he for m (s 1 , …, s nv(i) , x ), where:  s j =1 if v i,j was selected for placing a replica  s j =0 if v i,j was not selected for placing a replica  x is the total number of vertice s selected (so far) The set of actions of an Introduce node consists o f t wo a c- tions { Select, Do Not Select } and that of a Forget nod e will be the same as before ( {Forget} ) . We will show the main fun c- tions required by the framework. The n ormalize function will not be p resented (b ecause al l the inter mediate states will be valid) and the valid final states will be only those with x=k. updateCost(S, i, C) : C’=C for j=1 to nv(i)- 1 do if (( adjacent (v i,j , v i,nv(i) ) and ( S[ j] =S[nv( i)] =1 )) then C’=C’+pen(v i,j , v i,nv(i) ) return ( S,C’,true ) expandState(S, i, action) : let S=(s 1 , s 2 , …, s nv(i)-1 , x) if ( D i is an Introduce node ) then if ( action=Select ) then if ( x=k ) then return ( (), +Infinity, false ) S’=(s 1 , s 2 , …, s nv(i)-1 , 1, x+1) return upda teCost ( S’, i, T i-1 [S]+csel(v i,nv(i) ) ) else // action = Do Not Select S’=(s 1 , s 2 , …, s nv(i)-1 , 0, x) return ( S’, T i-1 [S], true ) else v i-1,j = the “forgotten” node S’=(s 1 , s 2 , …, s j-1 , s j+1 , …, s nv(i-1) , x ) return ( S’ ,T i-1 [S],true ) We w ill use the same b etter function as in the minimum p e- nalty coloring. T he time co mplexity o f the algorith m is O(k·2 pw ·n). We can in troduce several variations to t his pro b- lem, like de fining penalt y or profit values for each pair of adj a- cent vertices (u,v), where u is a selected vertex and v is not . These changes wo uld require a d ifferent updateCost functio n. G . Maximum Leaf Weigh ted Span ning Tree We are giv en a n undirected graph G with n>1 vertices and a nice path deco mposition of G. Each vertex i has an associated weight w(i) . We w ant to find a spanni ng tree of G such that the total weight o f the lea ves (ver tices of degree 1) of the spanning tree is maximum. This is a more ge neral version of the well - known Maximum Leaf Span ning T ree problem, which i s NP - hard in general. The states for a node D i have t he following form ((cid 1 , deg 1 ), (cid 2 , deg 2 ), …, (cid nv(i) , deg nv(i) ). cid j is the identifier of th e connected compo nent to w hich vertex v i,j b e- longs. deg j is the degree o f vertex v i,j in its connected comp o- nent. We are on ly intere sted i n the values 0, 1 and 2 (if v i,j has degree greater t han 2, we will keep its val ue at 2). All the c o n- nected components are trees. The identifier s of the connected components for m a partitio n, so the y must o bey the sa me rules as in the coloring problems presented previously. Every co n- nected component must have at least one representative vertex in the set of vertices of th e currently processed node i (i.e no connected component is “left behind”). W hen in troducin g a node, the ac tions are of three types: newComp onent , addAsLeaf and connectCompo nents . When forgetting a vertex v i-1,j , we must chec k that at least o ne other vertex v i-1,k with the same cid still exists; o therwise, the connected co mponent of v i-1,j would be “left behind”. T he onl y valid state is t he one in which all the vertices are in the same connec ted component (all the cids are 1). T i [S] will represent the maximum to tal weight of t he leaves of the connected components, such that very vertex in UD i b e- longs to a component and the vertices in D i are in state S. W e will only prese nt the setOfAc tions and expandSta te functions, because the o thers can be derived from the prob lems presented previously in this sectio n. setOfActions(i) : if ( D i is an Introduce node ) then actionSet={ newComponent } for j=1 to nv(i)-1 do if ( adjacent(v i,j ,v i,nv(i) ) ) then )} af, v { ( addA s Le actionSe t a c tionSet i,j   for all sets S={v i,j1 , v i,j2 , …, v i,jk } with k>1 do if ( v i,nv(i) is adjacent to all the ve rtices in S ) then , S)} Com pon ents { ( c onnect actionSet actionSet   return action Set else return { Forget } expandState(S, i, action) : let S=((cid 1 , deg 1 ), (cid 2 , deg 2 ), …, (c id nv(i)-1 , deg nv(i)-1 )) if ( D i is an Introduce node ) then if ( action=newComponent ) then newcid=max{cid 1 , …, cid nv(i)-1 }+1 S’=(( cid 1 , deg 1 ), …, (cid nv(i)-1 , deg nv(i)-1 ), (newcid, 0)) return (S’, T i-1 [S]+w (v i,nv(i) ), true) else if (action=(addAsLeaf, v i,j )) then C=w(v i,nv(i) ) if ( deg j =1 ) then C=C-w(v i,j ) S’ =( (cid 1 , deg 1 ), …, (cid j , min{2,deg j +1}, …, (cid j ,1)) return (S’, T i-1 [S]+C, true) else if (action=(connectComponents, SV )) then if ( k j k i j i c id c id SV v v    . , , , ) then return ( (), -Infinity, false ) newc id= } { ma x , j SV v cid j i  S’=(( cid 1 ,deg 1 ), …, (cid nv(i)-1 , deg nv(i)-1 ), (newcid, 2 )) C=0 for j=1 to nv( i)-1 do if (v i,j in SV) then if (deg j =1) then C=C+w(v i,j ) S’[j]=(newcid, min{ 2, deg j +1}) else if ( } | { , SV v c id c id k i k j   ) then S’[j]=(newcid, deg j ) return (S’, T i-1 [S]-C, true) else v i-1,j = the “forgotten” node if ( ) . ( , 1 j k k i cid cid j k v       ) then return ( (), -Infinity, false ) S’ =( (c id 1 ,deg 1 ), …, (cid j-1 ,deg j-1 ),(c id j+1 ,deg j+1 ) ,…, (cid nv(i)-1 ,deg nv(i)-1 ) return ( S’,T i-1 [S],true ) Using similar state definitions, w e can solve other spa nning tree pro blems, like find ing a spanning tree w ith th e maximum degree at most Q. In this ca se, we only need to solve a decis ion problem (like the first color ing p roblem we presented) and the degree values in a state S would range from 0 to Q. Of course, we would need to rej ect states in which the d egree o f so me vertex exceeds Q. Using the decision fun ction in a binary (or linear) sear ch proce dure, we can solve the we ll-k nown M in i- mum Degree Spanning T ree prob lem. H . Minimum Weighted Maximal Match ing A matching is a set of pairs of adj acent vertices, suc h that each vertex belongs to at most one pair. Given a w eight w(u,v) for each edge (u,v) of t he graph, the w eight of the matching is the sum o f the weights of the edges co mposing it. A matching is maximal if n o other edge can be added to t he matching. A minimum weighted matchi ng is a maximal matching with mi n- imum weight. In o rder to find such a matching, we will use states of the form (s 1 , …, s nv(i) ) for a node D i , where s j is eit her 1 or 0 (vertex v i,j belongs to th e matching o r not). When in tr o- ducing a vertex at a node D i , the ac tions are of two t ypes: ( Add, v i,j ), meaning that the introduced vertex is added to the matc h- ing together with one o f its neighbors v i,j w ith s j =0 and ( Do Not Add ). When forgetting a vertex v i-1 ,j , the al gorithm must check that all the neighbors v i-1,k of this vertex in t he last nod e D i-1 which contained the verte x are in state s j =1 (to make sure that the matching is maximal). For ever y va lid action ( Ad d, v i,j ), the cost returned b y the exp andState function will be T i-1 [S]+w(v i,j , v i,nv(i) ). For the other actions, the cos t does not change ( T i-1 [S] is returned). We will not present the code , due to lack of spa ce. I . Maximum Averag e Weight Path with Length Constrain ts Given a weight w(u) for each vertex of the grap h, we want t o find a path whose average weight (sum of the weights o f the vertices on the path divided by t he number o f vertices on the path) is maximum and whose length (number of vertices) is at least L a nd at most U. T he states will have the for m (s 1 , …, s nv(i) , x), where:  s j =2, if v i,j is the only vertex o n the path  s j =1 , if v i,j is one of the t wo end-vertice s of the path  s j =0 , if v i,j is not one of t he two end -vertices of the path  x is the total number of vertices o n the path (so far) The set o f actio ns o f a n Introduce node co nsists o f three a c- tions { Start Path, Select, Do Not Select } and that of a Forget node will be only { Forget}. The frame work functions are sim i- lar to those fro m the k-replic a placement proble m (except that the better function selects the maximum value). When selec t- ing a v ertex v i,j to b e part of the pat h, we al so select an ed ge from o ne o f the two end -verti ces to v i,j . As a r esult, the weight of t he p ath increases by w(v i,j )), the to tal number of vertices o n the pat h i ncreases b y 1 and t he sta te of the f ormer end -vertex which is now adjacent to v i,j is set to 0. When x=0, we also have the po ssibility of starting a n ew path, on which v i,j is th e only vertex (so far). Every inter mediate sta te is also a valid state. T he state of valid final states i s co mposed of those states S w here the num ber of vertice s x h as the property L ≤ x ≤ U. From t he set of valid final states, we w ill choose that state S=(s 1 , ..., s nv(P) , x) for which T P [S]/x is maximum. B y s imply changing the better function, we can also solve the minimu m weight average path with length constraint s problem. J . Optimizations for Partial Grid Graphs A (m,n) grid graph has m x n vertices arranged on m rows a nd n columns. Each vertex is ad jacent to at m ost four other v er ti c- es (on the ro ws above and belo w and the colu mns to the left and to the right). Such graphs appea r, for instance, in p rocessor interconnection networks. A partial (m,n) grid graph is a (m,n) grid graph in which some of the vertices and so me of the edges may be missing. These graphs have their pathwidth bounded b y min{m,n}. Let’s ass ume that one o f the dimensions is bo unded by a co nstant ( without loss o f generality, we w ill assume this dimension is n). A path deco mposition with path width n can be easily obtained by order ing the vertices from the fir st to the last row and, for each ro w , from the first to the last colu mn and introducing (and forgetting) t he vertices in this order. More o- ver, the vertices within a node D i are ordered using the same criterion. Partial grid graphs are planar graphs a nd b ecause o f this, the number of states in the dynamic progra mming alg o- rithm ca n be reduced by making use of the Catala n property (mentioned i n [9] ) . Let’s co nsider the minimum pat h (cyc le) cover prob lem. If a state S of a node D i contains bo th endpoints of two d ifferent p aths, then l et’s assume that v i, a and v i,b (a

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment