Layered graphs: a class that admits polynomial time solutions for some hard problems

The independent set on a graph $G=(V,E)$ is a subset of $V$ such that no two vertices in the subset have an edge between them. The MIS problem on $G$ seeks to identify an independent set with maximum cardinality, i.e. maximum independent set or MIS. $V* \subseteq V$ is a vertex cover $G=(V,E)$ if every edge in the graph is incident upon at least one vertex in $V*$. $V* \subseteq V$ is dominating set of $G=(V,E)$ if forall $v \in V$ either $v \in V*$ or $\exists u \in V*$ and $(u,v) \in E$. A connected dominating set, CDS, is a dominating set that forms a single component in $G$. The MVC problem on $G$ seeks to identify a vertex cover with minimum cardinality, i.e. minimum vertex cover or MVC. Likewise, CVC seeks a connected vertex cover (CVC) with minimum cardinality. The problems MDS and CDS seek to identify a dominating set and a connected dominating set respectively of minimum cardinalities. MVC, CVC, MDS, and CDS on a general graph are known to be NP-complete. On certain classes of graphs they can be computed in polynomial time. Such algorithms are known for bipartite graphs, chordal graphs, cycle graphs, comparability graphs, claw-free graphs, interval graphs and circular arc graphs for some of these problems. In this article we introduce a new class of graphs called a layered graph and show that if the number of vertices in a layer is $O(\log \mid V \mid)$ then MIS, MVC, CVC, MDS and CDC can be computed in polynomial time. The restrictions that are employed on graph classes that admit polynomial time solutions for hard problems, e.g. lack of cycles, bipartiteness, planarity etc. are not applicable for this class. \\ Key words: Independent set, vertex cover, dominating set, dynamic programming, complexity, polynomial time algorithms.


Introduction
The maximum independent set problem on a graph G = (V, E) seeks to identify a subset of V with maximum cardinality such that no two vertices in the subset have an edge between them. If V * ⊆ V is a maximum independent set or MIS for short of G then ∀u, v ∈ V * , (u, v) / ∈ E. In this article G is undirected, so, an edge (u, v) is understood to be an undirected edge.
Karp proposed a method for proving problems to be NP-complete [17]. The maximum independent set problem on a general graph is known to be NP-complete [15]. Certain classes of graphs admit a polynomial time solution for this problem. Such algorithms are known for trees and bipartite graphs [1], chordal graphs [2], cycle graphs [3], comparability graphs [6], claw-free graphs [7], interval graphs and circular arc graphs [8]. The maximum weight independent set problem is defined on a graph where the vertices are mapped to corresponding weights. The maximum weight independent set problem seeks to identify an independent set where the sum of the weights of the vertices is maximized. On trees, the maximum independent set problem can be solved in linear time [10]. Thus, for several classes of graphs MIS can be efficiently computed. Hsiao et al. design an O(n) time algorithm to solve the maximum weight independent set problem on an interval graph with n vertices given its interval representation with sorted endpoints list [12]. Several articles improved the complexity of the exponential algorithms that compute an MIS on a general graph [5,9]. Lozin and Milanic showed that MIS is polynomially solvable in the class of S 1,2,k -free planar graphs, generalizing several previously known results where S 1,2,k is the graph consisting of three induced paths of lengths 1, 2 and k, with a common initial vertex [13].
The minimum vertex cover problem on G seeks to identify a vertex cover with minimum cardinality, i.e. minimum vertex cover or MVC. If V * ⊆ V is MVC of G then ∀e = (u, v) ∈ E, u ∈ E ∨ v ∈ E. In this article G is undirected, so, an edge (u, v) is understood to be an undirected edge. The minimum dominating set, i.e MDS and the minimum connected dominating set i.e. CDS problems seek to identify a dominating set and a connected dominating set respectively of minimum cardinality. The MVC, MDS and CDS probelms on a general graphs are known to be NP-complete [15]. Garey and Johnson showed that MVC is one first NP-complete problem [15]. In connected vertex cover (CVC) problem, given a connected graph G, we are required to find vertex cover set C with minimum cardinality such that the induced subgraph G[C] is connected. Garey and Johnson proved that CVC is NP-complete [18]. For trees and bipartite graphs the minimum vertex cover can be identified in polynomial time [20,21]. Garey and Johnson proved that CVC problem is NP-hard in planar graphs with a maximum degree of 4 [15]. Li et. al. proved that for 4-regular graph CVC problem is NP-hard [19]. It is shown that for series-parallel graphs, which are a set of planar graphs, it shown that minimum vertex cover can be computed in linear time [23].
The minimum dominating set, i.e MDS and the minimum connected dominating set i.e. CDS problems seek to identify a dominating set and a connected dominating set respectively of minimum cardinality. Garey and Johnson showed that MDS on planar graphs with maximum vertex degree 3 and planar graphs that are regular with degree 4 are NP-complete [15]. CDS is NP-complete even for planar graphs that are regular of degree 4 [15]. Bertossi showed that the problem of finding a MDS is NP-complete for split graphs and bipartite graphs [22]. Cockayne et. al. proved that MDS in trees can be computed in linear time [4]. Haiko and Brandstadt showed that MDS and CDS are NP-complete for chordal bipartite graphs [24]. Ruo-Wei et. al. proved that for a given circular arc graph with n sorted arcs, CDS is linear in time and space [25]. Fomin et. al. propose an algorithm with time complexity faster than 2 n for solving connected dominating set problem [26].
The term layered graph has been used in the literature. The hop-constrained minimum spanning tree problem related to the design of centralized telecommunication networks with QoS constraints is NP-hard [14]. A graph that they call a layered graph is constructed from the given input graph and authors show that hop-constrained minimum spanning tree problem is equivalent to a Steiner tree problem. In software architecture the system is divided into several layers, this has been viewed as a graph with several layers. In this article we define a new class of graphs that we call layered graphs and design an algorithm to identify the corresponding minimum vertex cover.

Layered Graph
Consider a set of undirected graphs G 1 , G 2 , . . . G p on the corresponding vertex sets V 1 , V 2 , . . . V p and the edge sets Consider a graph G that is formed from ∀ i G i with special additional edges called inter-layer edges denoted as E ij where j = i + 1 and E ij denotes the edges between V i and V j . We call such a graph a layered graph denoted as LG whose layer number i is G i . Note that for any given i, E ij where j = i + 1 can be φ and ∀ l / ∈{i−1,i+1} E il = φ. Every vertex within a given layer gets a label from (1, 2, 3, . . . , k). Thus, Note that V ix is the vertex number x in layer i. However, in layer i the vertex number x need not exist. Further, if (V ix , V i+1 y ) ∈ E i i+1 then it follows that vertex x is present in layer i and vertex y is present in layer i + 1.
We define the following restrictions on a layered graph. Several of the primary restrictions can be combined. Please see Figure 1.
• The size of all graphs is restricted such that | V i |≤ k then a k-restricted layered graph i.e.
LG kr is obtained.
LG q kr denotes an LG with q layers.
LG q,n kr denotes an LG q kr with n vertices.
• If ∀ t for V it the only permissible edges are (V it , V jt ) where j ∈ {i − 1, i + 1} then a linear layered graph i.e. LLG is obtained. LLG kr denotes an LLG that is k-restricted. LLG q kr denotes an LLG kr with q layers.
LG q,n kr denotes an LLG q kr with n vertices.
• If every G i is required to be a connected component then a single component layered graph i.e. SLG is obtained.
• If G is required to be a connected component then a connected layered graph i.e. CLG is obtained.
This article primarily studies LG kr where every vertex within a given layer gets a label from (1, 2, 3, . . . k). The results being general are applicable for LLG, SLG and any combination thereof. Clearly, CDS, CVC are well defined only on SLG; further, the entire G must be a single component. The recursive process of generating a hypercube of dimension n+1 i.e. H n+1 from two copies of H n consists of creating the inter-H n edges ∀ i (v 1i , v 2i ) where v 1i and v 2i are the corresponding vertices from the first copy of H n and the second copy of H n respectively. Thus, the inter-layer edges of LLG are in fact akin to a subset of inter-H n edges because an inter-H n edge exists between every pair of corresponding edges. However, in an LLG the successive layers need not have all allowed edges; moreover, | V i | and | V i+1 | need not be identical.
The complete graph on k vertices is known as a clique on k vertices and it is denoted by K k . Consider a graph G formed from several copies of K k say G 1 , G 2 , . . . G p where in addition to the edges that exist in each of G i an edge is introduced between every pair u, v: u ∈ G i and v ∈ G i+1 . We denote this particular graph G that has p layers with K p k . The class of k-restricted layered graphs are in fact subgraphs of K p k . Thus, we call K p k as full LG p,n kr . Likewise, a LLG that is defined on p cliques where for any i, i + 1 for all values of l an edge is introduced between vertex l of layer i and vertex l of layer i + 1 is called as a full LLG p,n kr . The number of layers in LG kr i.e. q is bounded by n/k ≤ q ≤ n. Likewise, the number of connected components in this graph lie in [1, 2, 3 . . . n]. Recall that for any given i, E i i+1 can be φ; that is the adjacent layers need not have any inter-layer edges among them.
A subgraph of G induced by vertices u 1 , u 2 , . . . u i consists of all vertices u 1 , u 2 , . . . u i and all the edges defined on them. We design an algorithms that computes the cardinality of a MVC, CDS and CDS of any subgraph of K p k i.e.
LG q,n kr with polynomial time complexity when k = O(log n). Moreover, we compute the number of MISs, MVCs, CDSs and CDSs in LG q,n kr . The worst case time complexity analysis which shows that these problems can be solved in polynomial time for k = O(log n) holds for all these problems even though the time complexities are not identical when the parameter k is considered.
CDS problem is meaningful only for CLG. However, CVC problem does not require CLG because in the layers with no edges a vertex need not be selected. If every layer has at least one edge then CVC also requires CLG.

Algorithm
Consider a layered graph with q layers i.e. LG q,n kr with layers (1, 2, 3, . . . , q). We design a generic dynamic programming algorithm for all the problems. The CDS is applicable only when G is connected; thus, for these versions we are restricted to CLG. The specific details pertaining to each problem are elucidated. The layers are processed sequentially from the first to the last. Let S = q j=1 V * j be a candidate solution for a problem where V * j denotes the set of nodes that are chosen from layer j. The candidate sub-solutions or simply css for layer i and layers 1 . . . i are denoted as css i and ccss i respectively where cccs denotes a combined candidate subsolution for the first i layers. Likewise, css i,j and ccss i,j denote particular instances where the solution chosen in layer i equals j i.e. j is a k-bit variable that we call mask that denotes the chosen vertices. Further, ccss i,j potentially denotes several candidate sub-solutions of vertices from the first i layers where j is the mask corresponding to the layer i. We in general do not even store all these vertex sets but only the cardinality of the best option(s), such cardinality is called an optimum value. This is stored in the variable mask i,j and the number of solutions that yield the optimum value when the mask for layer i is j is stored in count i,j . The current layer requires the information only from the previous layer. So, only the variables of the current layer and the previous layer are maintained. The index 0 refers to the variables of the previous layer and index one refers to the same of the current layer. When the information for the index one is completely computed then it is overwritten onto the corresponding variables of index zero; the variables with index one are zeroed out and the next layer is processed (which becomes the current layer). This is a standard technique. Further, the overwriting of variables can be avoided by alternately assigning layers 1 and 0 as the current layer (the other becomes the corresponding previous layer). By employing extra space we can easily keep track of all possible solutions. However, we employ only O(k2 k ) space (for domination problems we employ O(k2 2k ) space ) in addition to the space required by the graph. If we employ O(n2 k ) space ( for domination problems, O(n2 2k ) space) where for each mask in each layer we store a best compatible mask from the previous layer then we can additionally generate a solution. However, if we want to generate all solutions then for each mask of a given layer we need to store all compatible masks of the previous layer that yield the optimum value. This further increases the space requirement.
We say that css i,j and ccss i−1,l are compatible if css i,j ccss i−1,l ∈ ccss i,j . That is the union of css i,j and ccss i−1,l yields a ccss for the first i layers. Note that compatibility is determined by css i,j and css i−1,l ∈ ccss i−1,l and the vertices chosen by ccss i−1,l in the earlier layers is irrelevant. This is a key feature.

Input
The Input consists of LG q,n kr that is specified in terms of M 1 , . . . , M q and I 1 , . . . , It must be noted that for a linear graph I i can just be a k dimensional vector and the corresponding computation is less expensive where I i [a] = 1 ⇐⇒ an edge between a ∈ V i , a ∈ V i+1 exists. The boolean valued function compatible is called to determine whether candidate sub-solutions (of the current layer and the subgraph induced up to the previous layer) can be combined; here the layer number i is implicit. For each mask j of a given layer i a function valid(i, j) determines if j is a feasible option for layer i. The helper function cardinality(j) returns the number of bits that are set in the binary representation of some mask j.
All algorithms consist of the following sequence of computational tasks.
• (ii) Extension: If j and l are compatible then store the cardinality of css i,j ccss i−1,l in mask i,j and the count of ccss i,j in count i,j . Corresponding to each css i,j if 2 k additional variables are present then update them (e.g. DS problems).
• (iii) Summarize: Layer q : execute (i) and (ii). Identify the optimum cardinality among ∀ j mask q,j and the corresponding count.
Each problem has specific characteristics. The compatibility criteria and other specifics for each of the problems is elucidated below.

MIS
Consider the structure of a MIS on LG q,n kr say V * = q j=1 V * j where V * j are the vertices in MIS from layer j. Clearly, V * j must be an IS. Let G 1 be the subgraph of LG q,n kr induced by V 1 = i j=1 V j and let G 2 be the subgraph of LG q,n kr induced by • f easible(j): the mask j must denote an IS for G i .
• compatible(j, l): the union of two ISs must be an IS.

MVC and CVC
Consider the VC V * = j=q j=1 V * i of LG q kr where V * i denotes the set of vertices in V * from layer i. Clearly, V * i is a VC for layer i. V * i depends only on V * i−1 and V * i+1 . Consider two adjacent layers p and p + 1. V * p V * p+1 must cover all edges inter-layer edges between layers p and p + 1. Specifically, V * = j=p+1 j=1 V * i must cover all edges in the corresponding induced subgraph including E p p+1 . Similar constraints hold for CMVC. Additionally the induced subgraph of V * must be a single connected component.
• f easible(j): the mask j must denote a VC for G i . For CVC j must be connected.
• compatible(j, l): the union of two VCs must be a VC for edges in G i , G i+1 and E i,j .
For CVC masks j and l must have at least on edge in between.

MDS and CDS
Let the MDS on LG q,n kr say V * = q j=1 V * j where V * j are the vertices in this MDS from layer j. Clearly, V * j need not be a DS of layer j because the V j can be dominated from any of V * j−1 , V * j , V * j+1 . It follows that V * p V * p+1 must dominate all vertices in layers p. Specifically, the inclusion of V * q in V * must ensure the domination of V q−1 V q . Consider mask = j in layer i. Say, css i,j ccss i−1,l dominates layer i − 1. However, this particular union of vertices leaves certain vertices in layer i undominated. The number of such choices are 2 k ; each choice is denoted by a k-bit variable that we call mask, here, a mask of exclusion. Further, when one processes layer i + 1 this information is significant. We show that O(2 k ) triples stored for each mask of a given layer suffice to compute MDS (CDC) of LF G kr . We aim to show that for a chosen mask j in layer i it suffices to store 2 k triples of the form (m x , s x , c x ). Here m x is the mask of the vertices that are not dominated in layer i, s x is the cardinality of the vertices chosen so far and c x is the number of choices corresponding to m x for a particular j in layer i. The particular mask in the previous layer that is the cause for a particular triple in the current layer need not be carried forward. So, for MDS and CDS mask i,j indicates an array of 2 k triples ∀ x (x, s x , c x ) where x is the mask of undominated vertices of layer i; s x , c x are the respective size and count.
Let mask j is chosen in layer i it potentially be combined with every mask ( O(2 k ) masks) of the previous layer. Thus, potentially (O(2 k )) triples need be stored. Further, the total number of triples of the form (m x , s x , c x ) is Ω(n.2 k ) because m x can potentially assume any of 0 . . . 2 k − 1, s x is O(n) and c x can in fact be exponential in n/k. Here we make the following critical observations.
• Let the chosen mask for layer i is j. When all the compatible vertex sets of the previous layer are considered then let the resultant triples for the choice of j in layer i be set S.
• In S for any two triples with the same mask we need only retain the triples with the least size. The other triples cannot lead to an optimum solution.
• If two triples have the same mask and the minimum size then they can be combined into one triple where the respective counts are added.
• Thus, only 2 k triples suffice for a chosen mask for layer i. Which implies 2 2k triples suffice ∀ j css(i, j). We store the information of only two layers. Thus, the space complexity is O(k2 2k ) • Thus, for a chosen mask for layer i potentially 2 2k triples of previous layer must be processed. That is, for all masks of layer i, 2 3k triples of previous layer must be processed. • f easible(j): For CMDS j must be connected. For MDS any j is valid.
• compatible(j, l): the union must dominate all vertices of V i−1 . For CDC masks j and l must have at least on edge in between.
• Extension: Performed as per critical observations listed above. The choice of the final layer must ensure that the final layer is dominated.

Algorithm Compatible
The function compatible receives two masks denoting chosen vertices from layers i and i + 1.
is the set of all vertices neighboring any vertex in V

Algorithm Generic Optimum
The algorithms for all the problems on LG kr is similar. We give a generic dynamic programming based algorithm. Some specific instances are shown in the Appendix. Initialization: ∀i mask 0i = mask 1i = 0; ∀i count 0i = count 1i = 0; mask ij : The minimum value of an vertex cover up to layer i where the chosen vertices of the layer i are given by the binary value of j. count ij : the number of ways the j th mask in layer i yields the corresponding minimum value. The time complexity for MIS, MVC and CVC is O(nk2 2k ) and the space complexity is O(k2 k ). The time complexity for MDS and CDS is O(n2 3k ) and the space complexity is O(k2 2k ).

Algorithm Generic Optimum
Input: LG q,n kr Output: The cardinality and the count for the resp. problem.

Correctness and complexity
The correctness is shown for MIS and MVC problems. The time complexities are identical and the analysis is given for MVC. The proofs of correctness for the remaining problems are similar. The time complexity for domination problems was presented earlier.

Theorem 1 Algorithm correctly computes the MIS on
LG q,n kr .
Proof: Consider the structure of MIS on LG q,n kr . Let G 1 be the subgraph of LG q,n kr induced by V 1 = i j=1 V j and let G 2 be the subgraph of LG q,n kr induced by V 2 = q j=i+1 V j . Consider the IS of G. Let M 1 and M 2 be the independent sets of G 1 and G 2 respectively. Let the set of edges crossing the cut C = (M 1 , M 2 ) be E C . It follows that the cardinality of an IS of G is | M 1 | + | M 2 | when there is no edge crossing C. Note that the only edges that can go across the cut are E i i+1 . Thus, the cardinality of MIS of LG q,n kr = max(∀ E C =φ | M 1 | + | M 2 |). This, is exactly being computed. The theorem follows. Another proof that can be given for this theorem is based on mathematical induction on subgraphs induced by the first i layers.
Likewise, count ij gives the number of ways an independent set of maximum cardinality that can be formed when the vertices chosen in the layer i are given by j. Thus, count qj corresponding to the maximum value of mask qj yields the total number of MISs.

Theorem 2 Algorithm correctly computes the MVC on
LG q,n kr . Proof: Consider the structure of MVC on LG q,n kr . Let G 1 be the subgraph of LG q,n kr induced by V 1 = i j=i V j and let G 2 be the subgraph of LG q,n kr induced by V 2 = q j=i+1 V j . Consider the VC of G. Let M 1 and M 2 be the vertex covers of G 1 and G 2 respectively. Let the set of edges crossing the cut C = (M 1 , M 2 ) be E C . It follows that the cardinality of an VC of G is | M 1 | + | M 2 | when every edge crossing C is covered by either M 1 or M 2 . Note that the only edges that can go across the cut are E i i+1 . Thus, the cardinality of MVC of LG q,n kr = min(∀ E C =φ | M 1 | + | M 2 |). This, is exactly being computed. The theorem follows. Another proof that can be given for this theorem is based on mathematical induction on subgraphs induced by the first i layers. Likewise, count ij gives the number of ways an vertex cover of minimum cardinality that can be formed when the vertices chosen in the layer i are given by j. Thus, count qj corresponding to the minimum value of mask qj yields the total number of MVCs. .

Theorem 3 Algorithm MVC on
LG q,n kr runs in polynomial time in n when k = O(log n). The space required is O(k 2 ).
Proof: We presume that I i , the 0-1 adjacency matrix for the subgraph induced by V i V i+1 where the edges are restricted to E i i+1 is given. Likewise, we assume that the 0-1 adjacency matrix M i for each of G i are given. Recall that LG q,n kr was formed from G 1 , G 2 , . . . G q . For a linear graph, I i is just a k−dimensional vector where if bit j is set then there is an edge between V ij and V i+1 j .
• The initialization step requires O(2 k ) time. • Given two masks mask1, mask2 for layers i, i + 1 respectively and I i it can be directly determined if their union is a VC of a subgraph induced by i+1 i V j of LG q,n kr in O(k 2 ) time.
• In order to determine the MVC up to layer i whose mask is j; j must be checked for compatibility with all masks of the previous layer. Thus, O(k 2 2 k ) time is required. For all masks of the current layer O(k 2 2 2k ) time is required. For all layers, the time required is maximized when each layer has k vertices yielding O(n/kk 2 The time complexity is clearly exponential in k; however, if k = O(1) the time complexity is O(n). The time complexity remains polynomial when k = O(log n). The space required is O(k2 k ) because for two layers we store 4.2 k mask and count variables each of size k.

Conclusions
A new large class of graphs called layered graphs have been defined. These graphs can have exponential number of cycles. This class includes a subset of bipartite graphs and a subset of trees on n vertices. The restrictions that are employed on graph classes that admit polynomial time solutions for hard problems, e.g. lack of cycles, bipartiteness, planarity etc. are not applicable for this class. The computation of hard problems on these graphs along with the count of the corresponding optimum solutions is shown to be in P when layer size is O(log | V |). LG 3,12 4r . 1b) LLG 3,10 4r . 1c) SLG 3,11 4r . 1d) SLLG 3,11 4r . In single component graphs, each layer has exactly one connected component. The vertices are labeled 1, 2, 3, 4 within the given layer. The edges between the vertices of a given layer are shown with thick lines whereas an e ∈ E i i+1 is shown with a dotted line. The graph is labeled. In a linear graph the edges ∈ E i i+1 connect the vertices with identical labels from adjacent layers.

Acknowledgments
Authors thank Amma for her guidance. This article is based on technical report UTDCS-02-17. Figure 2: From left to right: 1a) LG 3,12 4r . 1b) LLG 3,10 4r . 1c) SLG 3,11 4r . 1d) SLLG 3,11 4r . In single component graphs, each layer has exactly one connected component. The vertices are labeled 1, 2, 3, 4 within the given layer. The edges between the vertices of a given layer are shown with thick lines whereas an e ∈ E i i+1 is shown with a dotted line. The graph is labeled. In a linear graph the edges ∈ E i i+1 connect the vertices with identical labels from adjacent layers.

Appendix
The generic algorithm was presented earlier. Here, we state two specific algorithms for MIS and MVC respectively.

Input:
LG q,n kr Output: The cardinality of MIS and the count of the maximum independent sets. Initialization: ∀i mask 0i = mask 1i = 0; ∀i count 0i = count 1i = 0; //mask ij : The maximum value of an independent set up to layer i where the chosen //vertices of the layer i are given by the binary value of j. //count ij : the number of ways the j th mask in layer i yields the corresponding maximum value. //is(j) is a boolean function that returns true if the vertex assignment in the current layer //corresponding to the binary value of j forms an IS. Otherwise it returns false. //∧ is the bitwise AND operator. //cardinality(j) is the number of bits that are set in the binary representation of j. // For each mask ij one k-bit variable that remembers the mask of the layer i − 1 that // yielded mask ij will help in constructing MISs. Union of such masks (1/layer) is an MIS. // This will require O(n/k2 k ) additional space. Current version needs only O(2 k ) space. for (i =0,...,2 k − 1) do if is(i) for layer 1 then count 0i = 1; mask 0i = 1; // No. of valid ISs of layer 1 end if end for