Layered Graphs: Applications and Algorithms

: The computation of distances between strings has applications in molecular biology, music theory and pattern recognition. One such measure, called short reversal distance, has applications in evolutionary distance computation. It has been shown that this problem can be reduced to the computation of a maximum independent set on the corresponding graph that is constructed from the given input strings. The constructed graphs primarily fall into a class that we call layered graphs. In a layered graph, each layer refers to a subgraph containing, at most, some k vertices. The inter-layer edges are restricted to the vertices in adjacent layers. We study the MIS, MVC, MDS, MCV and MCD problems on layered graphs where MIS computes the maximum independent set; MVC computes the minimum vertex cover; MDS computes the minimum dominating set; MCV computes the minimum connected vertex cover; and MCD computes the minimum connected dominating set. MIS, MVC and MDS run in polynomial time if k = Θ ( log | V | ) . MCV and MCD run in polynomial time if k = O (( log | V | ) α ) , where α < 1. If k = Θ (( log | V | ) 1 + (cid:101) ) , for (cid:101) > 0, then MIS, MVC and MDS run in quasi-polynomial time. If k = Θ ( log | V | ) , then MCV and MCD run in quasi-polynomial time.


. , π[n].
A short reversal is either a (1-flip) or an adjacent swap.The short reversal distance is the minimum number of short reversals required to transform a signed string into another compatible string.Two strings are compatible under short reversals if and only if their unsigned versions, i.e., the strings whose signs are disregarded, are compatible [1].The computation of the short reversal distance between α and β is reduced to the computation of the cardinality of the maximum independent set on a conflict graph constructed from α and β.It has applications in HOX gene clusters in vertebrate evolution [2,3].In music theory, a composition is represented as a string.The smaller the distance between two patterns (compositions), the more similar they are [4].
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 the 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 [5].The maximum independent set problem on a general graph is known to be NP-complete [6].Certain classes of graphs have a polynomial time solution for this problem.Such algorithms are known for trees and bipartite graphs [7], chordal graphs [8], cycle graphs [9], comparability graphs [10], claw-free graphs [11], interval graphs and circular arc graphs [12].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 weighted independent set problem can be solved in linear time [13].Thus, for several classes of graphs, MIS can be efficiently computed.
Hsiao et al. designed 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 a sorted endpoints list [14].Several articles improved the complexity of the exponential algorithms that compute an MIS on a general graph [15,16].Lozin and Milanic showed that MIS is polynomially solvable for 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 [17].
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 the MVC of G, then ∀e = (u, v) ∈ E, u ∈ V * ∨ v ∈ V * .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., MCD) problems seek to identify a dominating set i.e., DS and a connected dominating set i.e., CDS, respectively, with minimum cardinalities.The MVC, MDS and MCD problems on general graphs are known to be NP-complete [6].Garey and Johnson showed that MVC is one of the first NP-complete problems [6].In connected vertex cover problems (i.e., MCV), given a connected graph (G), a connected vertex cover (i.e., CVC) with minimum cardinality is sought.Garey and Johnson proved that MCV is NP-complete [18].For trees and bipartite graphs, the minimum vertex cover can be identified in polynomial time [19,20].Garey and Johnson proved that the MCV problem is NP-hard in planar graphs, with a maximum degree of 4 [6].Li et al. proved that for 4-regular graphs, the MCV problem is NP-hard [21].It has been shown that for series-parallel graphs, which are a set of planar graphs, the minimum vertex cover can be computed in linear time [22].
Garey and Johnson showed that the MDS problems on planar graphs with maximum vertex degree 3 and planar graphs that are regular with degree 4 are NP-complete [6].MCD is NP-complete even for planar graphs that are regular with degree 4 [6].Bertossi showed that the problem of identifying a MDS is NP-complete for split graphs and bipartite graphs [23].Cockayne et al. proved that MDS in trees can be computed in linear time [24].Baker designed various approximation algorithms for planar graphs [25].Muller and Brandstadt showed that MDS and MCD are NP-complete for chordal bipartite graphs [26].Ruo-Wei et al. proved that for a given circular arc graph with n sorted arcs, MCD is linear in time and space [27].Fomin et al. proposed an algorithm with a time complexity faster than 2 n to solve the connected dominating set problem [28].
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 quality of service (QoS) constraints is NP-hard [29].A graph known as a layered graph was constructed from a given input graph, and the authors showed that the hop-constrained minimum spanning tree problem is equivalent to the 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 algorithms for various graph-theoretic problems.

Layered Graph
Consider a set of undirected graphs, G 1 , G 2 , . . ., G q , on the corresponding vertex sets (V 1 , V 2 , . . . ,V q ) and the edge sets (E 1 , E 2 , . . . ,E q i.e., G i = (V i , E i )).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, where the i-th layer is G i .Note that for any given i, E ij , where j = i + 1 can be φ and ∀ l =i+1 E il = φ.Every vertex within a given layer gets a label from (1, 2, 3, . . ., k).Thus, V i ⊆ {V i1 , V i2 , . . ., V ik }.Note that V ix is the vertex number, x, in layer i.However, in layer i, the vertex number, x, may 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 defined the following restrictions on a layered graph.Several of the these restrictions can be combined.Please see Figure 1.• LG k , is obtained.
LG q k denotes an LG with q layers.LG n,q k denotes an LG q k with n vertices.The problems of computing the adjacent swap distance between unsigned strings, adjacent swap distance between signed strings and short reversal distance were addressed in [1].If the alphabet is Σ, |Σ| is k, the source string is α and the destination string is β and the length of α (and β) is n, a pairing diagram can be drawn for α and β, where all elements of α and β are treated as vertices, and perfect matching is performed on all 2n vertices, where each edge corresponds to (α[i], β[j]) (here, both α[i], β[j] denote the same symbol [1]).The solutions to the above problems are based on optimum pairing (in contrast to any perfect matching), where there is an edge from the i-th occurrence of a symbol x in α to the i-th occurrence of x in β; the corresponding pairing diagram is the optimum pairing diagram.The solutions for adjacent swap distances are complete.However, the solution suggests that the short reversal distance is partial; it can solve very few sub-cases.Several distance problems on strings have been shown to be NP-complete [30].However, the complexity of short reversal distance problem is unknown.The short reversal distance was studied in [2].It was shown that the edges corresponding to two consecutive occurrences of a symbol x in optimum pairing form a special edge-pair if they meet certain criteria.A conflict graph, G, is constructed from an optimum pairing diagram where a vertex denotes a special edge-pair, and an edge exists between a pair of vertices that are in conflict.The computation of the short reversal distance is reduced to the computation of MIS on G. G consists of several subgraphs, ∀ i G i , each having, at most, k vertices, where each vertex corresponds to a symbol in Σ.Each G i is a subgraph of the K k clique.The vertices, u ∈ G i , v ∈ G j (i = j), can have a conflict only if they correspond to the same symbol.Further, they share a common edge in the optimum pairing diagram.In this particular scenario, the layered graphs arise naturally.Further, such layered graphs are LLGs.In this framework, the computation of MIS on a LLG is a necessary component in the computation of the corresponding short reversal distance.
Considering a tribal society S consisting of some villages on a bank of a river, a village consists of a few families where each family has its own family-head.The family-heads of a given village know one another, and they also interact with specific family-heads of adjacent villages for trade (of produce) and partnership (collaboration in farming etc.).If one models this society as a social network, where a family-head is denoted by a vertex and an interaction (among family-heads) is denoted by an edge, then one obtains a layered graph.In this social network, identifying the smallest set of influencers is a natural pursuit (whose solution is given by computing MDS).These applications motivate the study of MIS, MDS and other graph theoretic problems on layered graphs.In general, graph theoretic problems, like subgraph isomorphism, and its variations have extensive applications in computational biology, e.g., references [31,32].
This article designs algorithms for LG k where every vertex within a given layer gets a label from {1, 2, 3, . . ., k}.The results are applicable for any restrictions of LG k , like LLG, SLG, etc.Consider a layered graph, G, whose first a layers and last b layers do not have any edges.The graph is not a CLG; however, the MCV of G is the same as the MCV of the subgraph where the first a and the last b layers are removed.Further, if every layer has at least one intra-layer edge, then MCV can be computed only on CLG.MCD is well defined only for CLG because it must dominate all vertices.
The complete graph on k vertices, a clique on k vertices, is denoted by K k .Consider a graph, G, formed from several copies of K k , say G 1 , G 2 , . . ., G q , where, in addition to the edges that exist in each of G i , an edge is introduced between every pair, uv: u ∈ G i and v ∈ G i+1 .We denote this particular graph, G, that has q layers with K q k .The class of k-restricted layered graphs are in fact subgraphs of K q k .Thus, we call K q k a full LG q k .Likewise, a LLG that is defined on q 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 a full LLG q k .The number of layers in LG k i.e., q is bound by n/k ≤ q ≤ n.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 restricted to them.We designed algorithms that compute the cardinalities of MVC, MIS and MDS of any subgraph of K q k i.e., LG n,q k in polynomial time when k = O(log n) and the cardinalities of MCV and MCD in polynomial time when k = O((log n) α ), α < 1.Additionally, these algorithms report the corresponding numbers of MISs, MVCs, MDSs, MCVs and MCDs in LG n,q k .

Algorithm
Consider a layered graph with q layers, i.e., LG n,q k with layers (1, 2, 3, . . ., q).We designed a generic dynamic programming algorithm for all of the problems.However, certain restrictions exist corresponding to the problem at hand.The specific details pertaining to each problem are elucidated along with its solution.For example, MCD is meaningful only when the underlying graph is connected, i.e., the input graph is restricted to CLG.
We denoted the vertices chosen in a particular layer with a k-bit variable that we called mask.The pth bit of the mask was set to one to include the pth vertex.Otherwise, the bit was set to zero and the vertex was excluded.Let S = q i=1 V * i be a candidate solution for a problem where V * i denotes the set of nodes that are chosen from layer i.The candidate sub-solution for layer i is denoted cs i .For layers 1, . . ., i, a combined candidate sub-solution is maintained, denoted ccs i .Likewise, cs i,j and ccs i,j denote the sub-solutions (of layer i and first i layers respectively), where the vertices chosen from layer i are denoted by mask j.Only the cardinality of the best options is stored; such cardinality is called an optimum value.This is stored in the variable sol i,j , and the corresponding number of solutions that yield the optimum value is stored in count i,j .In this article, an optimal solution is a solution that corresponds to the optimum value.We say that cs i,j and ccs i−1,l are compatible if cs i,j ccs i−1,l ∈ ccs i,j .That is, the union of cs i,j and ccs i−1,l yields a ccs for the first i layers.Note that compatibility is determined by cs i,j and cs i−1,l ∈ ccs i−1,l , and the vertices chosen by ccs i−1,l in the earlier layers are irrelevant.This is a key feature.

Input
The input consists of LG n,q k which is specified in terms of M 1 , . . ., M q and I 1 , . . ., I q−1 , where M i is the 0-1 adjacency matrix for layer i, i.e., G i .I i is the 0-1 adjacency matrix for E i,i+1 .Rows 1, 2, . . ., k of I i correspond to vertices V i1 , V i2 , . . ., V ik , and columns 1, 2, . . ., k of I i are vertices V i+1 1 , V i+1 2 , . . ., V i+1 k .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 adjacency matrix M i , for layer i, is a matrix of dimensions k × k, which means it requires O(k 2 ) space.Similarly, each G i also requires O(k 2 ) space.Therefore, the total space required for the input graph is O(nk), since each layer requires O(k 2 ) space, and there are O(n/k) layers.
The Boolean valued function compatible (please see Algorithm 1) determines whether the candidate sub-solutions (of the current layer and the subgraph induced by vertices of all previous layers) can be combined; here, the layer number, i, is implicit.For each mask, j, of a given layer, i, the 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 mask j.
All algorithms consist of the following sequence of computational tasks: • Repeat (i) and (ii) for all layers 1, . . ., q − 1.

•
(ii) Extension: If j and l are compatible, then store the cardinality of cs i,j ccs i−1,l in sol i,j and the count of ccs i,j in count i,j .• (iii) Summarize: At layer q :, execute (i) and (ii).Identify the optimum cardinality among ∀ j sol q,j and the corresponding count.
A particular problem has specific characteristics.In the sequel, where a problem is dealt with in detail, the corresponding validity/compatibility and other specifics are elucidated.

Algorithm 1 Compatible Algorithm
Input: LG k , j, l, and I.
//The function call: compatible(j, l).l: Mask for layer i. Output: 0 (incompatible) or 1 (compatible).//j: Mask for layer i + 1.I denotes matrix for E i i+1 .// bit c (i) returns true if bit c is set in i, otherwise, it returns false.
Case MIS: // Input: two valid MISs of two adjacent layers if independent(j, l) then // independent(j, l): for any a, b : bit a (l) and bit b (j): is the set of all vertices neighboring any vertex in V Case MCD: // Input: two masks of two adjacent layers, // For each component of l, ∃c ∈ l: (∃ d : // dom(j, l): D ← cs i,l cs i+1,j Adj(cs i,l ) Adj(cs i+1,j ) return 1; // i < q − 1: if V i ⊆ D then return 1; otherwise return 0; else // i = q − 1: if V i V i+1 ⊆ D then return 1; otherwise return 0; return 0; //V i or V i V i+1 is not dominated.O(k 2 ) algorithm.end if // Adj(V) is the set of all vertices neighboring any vertex in V

MIS
Consider the structure of an MIS on LG n,q k .Say, V * = q j=1 V * j where V * j are the vertices in MIS from layer j.Clearly, V * j must be an independent set.(please see Figure 2).Let G 1 be the subgraph of LG n,q k induced by V 1 = i j=1 V j , and let G 2 be the subgraph of LG n,q k induced by when there is no edge crossing C.Only the edges in E i i+1 need to be considered.Thus, the cardinality of an MIS of LG n,q • 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 MCV
Consider a vertex cover k where V * j denotes the set of vertices in V * from layer j.Clearly, V * j is a VC for layer j (please see Figure 3).V * j depends only on V * j−1 and V * j+1 .Consider two adjacent layers, p and p + 1.
p+1 must cover all inter-layer edges between layers p and p + 1.Specifically, V * = p+1 j=1 V * j must cover all edges in the corresponding induced subgraph, including E p p+1 .Similar constraints hold for MCV.Additionally, for MCV, the induced subgraph of V * must be a connected component (please see Figure 4).In the sequel, the time and space complexity analyses for these problems are presented.
Clearly, each layer must choose a mask that is a VC.In the case of MCV, when considering a mask, j, for the current layer, i, the following cases exist: (a) The previous layer mask, l, corresponds to one component.(b) l has more than one component, i.e., the set of vertices denoting l is partitioned into several connected components.

Case (a):
For layer i, mask j is infeasible if either (I) vertices corresponding to j and l have no edges among them or (II) all edges in I i are not covered.Otherwise, j is feasible.If at least one edge exists across j and l: (i) If j is a single connected component, then the result is also a single component (consisting of all chosen vertices).(ii) If j has more than one connected component and all of them connect to l, then the result is also a single component.(iii) If j has more than one connected component and only some of them connect to l, then the result consists of many components.All components from j connected to l become one component and the rest are separate components.

Case (b):
Every component from the previous layer corresponding to mask l must connect to some component in the current layer.Otherwise, the pair j and l is infeasible for layer i.For feasible pairs the following possibilities exist: (i) Every component in l has an edge with exactly one component in j.Here, the partition is determined by j. (ii) A component, C, in l has edges with C 1 , . . ., C a in j.Then, C 1 , . . ., C a can be merged into one component as they are connected through C.
A particular partitioning of the current layer can occur due to various choices of l.For each partition corresponding to j, the sub-solution is stored with minimum cardinality.Thus, for each mask, j, there are, at most, B k (k-th Bell number) solutions stored.When mask x is chosen for the last layer, then the vertices of the mask must be connected to the components of the previous layer and yield a single component.

•
f easible(j): Mask j must denote a VC for G i .• compatible(j, l): The union of two VCs must be a VC for edges in G i−1 , G i and I i−1 .i is the current layer.For MCV, all components of l must have edges with vertices in j.If i = q, then V * must be one component.

MDS and MCD
Let an MDS of LG n,q k be V * , such that, V * = q j=1 V * j , where V * j represents the vertices in this MDS from layer j.Clearly, V * j may not be a dominating set of layer j because the vertices of V j can be dominated by any subset of A vertex that is not dominated is undominated.Consider mask j in layer i, where cs i,j ccs i−1,l dominates layer i − 1.This particular subset of vertices can leave some vertices in layer i undominated.The number of such choices is 2 k ; each choice is denoted by a k-bit variable that we call a mask-here, a mask of exclusion.Further, when one processes layer i + 1, this information is critical.We show that the O(2 k ) triples stored for each mask of a given layer suffice to compute MDS of LG k .For a chosen mask, j, in layer i, it suffices to store 2 k triples of the form (u, s, c).Here, u is the mask of the vertices that are undominated in layer i, s is the cardinality of the vertices chosen so far and c is the number of choices corresponding to u for a particular j in layer i. MCD has an additional requirement compared to MDS, i.e., V * must form a single component (please see Figure 6).For possible combinations of component layouts of the current and previous layer masks, see MCV.For MCD, it suffices to store O(B k 2 k ) triples of the form (lo, un, r), where B k is the k-th Bell number.This corresponds to O(B k ) component layouts, lo, for a mask, j, and O(2 k ) masks un of the vertices that are not dominated in layer i and O(2 k ) triples r of the form (m, s, c) for every unique pair of (lo, un).Here, m is the mask of the current layer that produces the respective (lo, un) pair, i.e., mask j, while s and c are same as that for MDS, corresponding to mask m and pair (lo, un).The particular mask in the previous layer that is the cause of a particular triple in the current layer needs not be carried forward.So, for MDS, sol i,j indicates an array of 2 k triples.As for MCD, it indicates O(B k 2 k ) triples where O(2 k ) triples are associated with each of the O(B k 2 k ) unique pairs of (lo, un).Also, when k = O(log n) for MDS and k = O(log n) α where α < 1 for MCD, the algorithm runs in polynomial time.Consider the following analysis for MDS.Let mask j be chosen in layer i; it can 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 (un, s, c) is Ω(n.2 k ), because un can potentially assume any 0, . . ., 2 k − 1; s is O(n) and c can, in fact, be exponential in n k .Here, we make the following critical observations:

•
Let the chosen mask for layer i be 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 as S.

•
In S, for any two triples with the same mask, we need only to retain the triples with the smallest size.The other triples cannot lead to an optimal 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 cs i,j .The information of only two layers is stored.Thus, the algorithm needs O(k2 2k ) space.This is in addition to the space required by the input graph, which is O(nk).For k = O(log n), O(k2 2k ) is the dominating term, so the space complexity is O(k2 2k ).• Thus, for a chosen mask for layer i, potentially 2 2k triples of the previous layer must be processed.That is, for all masks of layer i, a total of 2 3k triples must be processed.• Consider mask j in layer i and mask l in layer i − 1. Recall that there are 2 k triples stored corresponding to mask l in layer i − 1.All the vertices that are covered by the combination of j and l in layer i − Similar constraints hold for MCD.We carry forward the existing connected components, and eventually, when the final layer is processed, all the components must be connected.The MCD algorithm is explained in detail in Theorem 4 along with time and space complexity analyses.The current layer in the following functions is i.

•
f easible(j): Any j is valid.• compatible(j, l): Tthe union must dominate all vertices of V i−1 .For MCD, all components of l must have edges with vertices in j.If i = q, then V * must be one component and it must dominate V q also.• Extension: Performed as per the observations listed above.

Compatible Algorithm
Given candidate sub-solutions for consecutive layers one must determine if their union is a feasible sub-solution.The following algorithm determines the same for the problems addressed in this article.

Generic Optimum Algorithm
The algorithms (please see Algorithm 2) for the MIS, MVC and MDS problems on LG n,q k are similar, while those for MCV and MCD must additionally ensure connectedness criterion.We give a generic dynamic programming based algorithm for both sets of problems.Some specific instances are shown in Appendix A.
Initialization: ∀i sol 0i = sol 1i = 0; ∀i count 0i = count 1i = 0; sol ij : The optimum value (of IS, VC, MCD, etc.) up to layer i, where the chosen vertices of layer i are given by the binary value of j. count ij : The number of ways that the j-th mask in layer i yields the corresponding optimum value.

Input: LG n,q k
Output: The cardinality and corresponding count for the respective problem.for (i = 0, ..., 2 k − 1) do if valid(1, i) then //for layer 1 count 0i = 1; sol 0i = cardinality(i); // For all valid masks, set their count end if end for for (i = 2, ..., q) do //For layers 2 through maximum for (j = 0, ..., 2 k − 1) do //For all masks of the current layer Compose larger sub-solutions by considering all compatible masks of the previous layer and any accompanying information.end for//Masks of previous layer end for//For all layers, The current layer being processed is the final layer.best ← 0; sum ← 0; for (i = 0, ..., 2 k − 1) do Identify best, the cardinality of an optimal solution.end for for (i = 0, ..., 2 k − 1) do Compute sum, the count of the optimal solutions.end for return(best, sum)

Correctness and Complexity
The Algorithm Generic Optimum when adapted to a specific problem, say MVC, is referred to as Algorithm MVC.The correctness is shown for MIS, MVC and MCD problems.Proof.Let G = (V, E) be a graph and let V be partitioned into V 1 , V 2 .Further, let I 1 , I 2 be the ISs of the graphs induced by V 1 , V 2 , respectively, and let I = I 1 I 2 .If we consider the cut, C = (I 1 , I 2 ), on I, where E C is the set of edges crossing the cut, then it follows that , and let G 2 be the subgraph of LG n,q k , induced by V 2 = q j=i+1 V j .Consider the IS of G. Let I 1 and I 2 be the independent sets of G 1 and G 2 , respectively.Let the set of edges crossing the cut, C = (I 1 , I 2 ), be E C .It follows that I = I 1 I 2 is an IS of G with cardinality | I 1 | + | I 2 | when there is no edge crossing C.Only the edges in E i i+1 need to be considered.Thus, the cardinality of an MIS of LG n,q k is equal to When the last layer is processed, the cardinalities of the ISs of subgraphs induced by both V and V − V q are known.Further, these ISs have maximum cardinalities with respect to the vertices chosen in layers q − 1 and q, respectively.The theorem follows.Likewise, count ij gives the number of ways that an independent set of maximum cardinality can be formed when the vertices chosen in layer i are given by j.Thus, the count qj corresponding to the maximum value of sol qj yields the total number of MISs.Proof.Consider the structure of MVC on LG n,q k .Let G 1 be the subgraph of LG n,q k induced by V 1 = i j=1 V j , and let G 2 be the subgraph of LG n,q k induced by V 2 = q j=i+1 V j .Consider a 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, when every edge crossing C is covered by either M 1 or M 2 .Note that the only edges from E i i+1 = E C can go across the cut.Thus, the cardinality of the MVC of LG n,q When the last layer is processed, this property is ensured.The theorem follows.Similarly, count ij gives the number of ways that a vertex cover of minimum cardinality can be formed when the vertices chosen in the layer i are given by j.Thus, count qj corresponding to the minimum value of sol qj yields the total number of MVCs.
Theorem 3. The MVC Algorithm on LG n,q k runs in polynomial time in n when k = O(log n).The space required is O(nk).
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 is given.Recall that LG n,q k 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 a mask for layer i, it can be determined whether VC is valid in O(k 2 ) time with M i .That is, for any two M i [a][b] that are set, the mask should have either a bit a or a bit b set.

•
Given I i and two masks, mask1 and mask2, for layers i and i + 1, respectively, it can be directly determined whether the union of the two masks is a VC of the subgraph induced by 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 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); specifically, O(n 3 log n) when k = log n.The additional space required is O(k2 k ) because for two layers, 4.2 k masks and count variables are stored, each of size k.The space required is O(nk) to store the graph and an additional space of O(k2 k ) that is needed by the algorithm.When k = O(log n), the space complexity is O(nk).
Proof.The time complexities of all these algorithms can be written as . Thus, when k = Θ((log n) 1+ ) for > 0, the complexities for all the algorithms will be quasi-polynomial.Theorem 4. The MCD Algorithm correctly computes the cardinality of a connected minimum dominating set for LG k with a time complexity of O(n 1+ ) for any > 0 when k = O(log n) α and α < 1.The space complexity of the algorithm is O(nk).
Proof.First, we show that the algorithm correctly computes the cardinality of a connected minimum dominating set.Consider the structure of CDS on a connected graph, G. Let V be arbitrarily partitioned into and let E C be the edges that cross this cut.Clearly, Let G be a LG n,q k ; in particular, let G be a DSs of G 1 and G 2 , respectively.Let C be the cut (M 1 , M 2 ), and let E C be the edges that cross this cut.Note that E C = E q−1 q .When the algorithm processes layer q, it chooses where M forms a connected component in G. Thus, the theorem follows.Similarly, count ij gives the number of ways a CDS of minimum cardinality can be formed when the vertices chosen in layer i are given by j.Thus, ∀ j Σcount qj corresponding to the minimum value of ∀ j sol qj yields the total number of MDSs.
The time complexity of the algorithm is analyzed below.We presumed that similar prerequisites as in Theorem 3 were provided.The steps are presented below.

•
A global structure, sol, consisting of sol 0 and sol 1 , corresponding to the previous and current layers, is maintained for the whole algorithm.The final solution for the problem can be determined just by using information from sol 0 and sol 1 .This structure is maintained for the whole algorithm and not for every layer.
• sol 0 and sol 1 consist of a maximum of B k 2 k triples of the form (lo, un, r).This corresponds to a maximum of B k component layouts (lo), 2 k masks, un undominated vertices of the current layer and a maximum of 2 k triples, r, of the form (m, s, c), for every unique pair (lo, un).Here, m is the mask of the current layer that produced the respective (component layout, undominated vertices) pair; s is the minimum cardinality of the sub-solution corresponding to mask m and pair (lo, un); and c is the count of s corresponding to mask m and pair (lo, un).

•
Throughout the algorithm, sol 0 and sol 1 are maintained by clearing sol 0 when the current layer is processed and the information of sol 1 is used as sol 0 for the next layer.• sol 0 is initialized with the triple (lo, un, r), corresponding to 2 k masks of the first layer.The initialization takes O(k 2 2 k ).

•
A candidate sub-solution for layers 1, . . ., i induces connected components in layer i that are defined in terms of vertices of layer i.We call this the component layout.

•
The number of component layouts is upper bounded by B k , the number of ways of partitioning k vertices of a layer.Here, From Lemma 1, we know that f (n)! = O(n ), for any > 0. • A mask j of the current layer can be combined with a component layout for mask l of the previous layer to form a new component layout for the current layer.With the same mask, l, j can form a new mask corresponding to the undominated vertices of the current layer.

•
Every such unique pair of (lo, un), where lo is component layout and un is mask of undominated vertices, is maintained, and a list of triples r, consisting of triples of the form (m, s, c), is associated with it.Here, m is the current layer mask, s is the minimum cardinality of the sub-solution corresponding to m, and c is the count of s.The number of such tuples, (lo, un, r), is upper bounded by B k 2 2k , where B k 2 k is the possible number of unique pairs of (lo, un), and 2 k is the possible number of triples that can exist for each pair.

•
Starting from the i-th layer, i > 1, every 2 k masks of the current layer and the triple values from the previous layer are used to generate the triples for the current layer.

•
For a unique pair (lo, un) in the previous layer, if mask j dominates the undominated vertices of mask un, and forms a connected component with the layout, lo, then we consider that a sub-solution using mask j is feasible.Here, a mask, j, and a component layout, lo, are considered to form a connected component if every component in lo has at least one edge with a node in mask j.Each such check takes O(k 2 ) time.So, the total time to determine if a sub-solution with mask j is feasible is O(k 2 ).

•
If a mask, j, can feasibly give a sub-solution, then it is combined with the component layout, lo, of the previous layer to form a new component layout for the current layer corresponding to mask j.This is performed using a DFS which takes O(k 2 ) for the given input matrix.

•
Mask j is then combined with mask l of the previous layer, corresponding to the pair (lo, un) that is under consideration, to form a mask for the current layer vertices that are not dominated by j or l.This takes O(k 2 ) time.

•
Using the mask, j, of the current layer and minimum cardinality, s, for the pair (lo, un) of the previous layer, the new cardinality for the sub-solution is computed.

•
The count of the new cardinality will be same as that of c of the (lo, un) pair for the previous layer.

•
This new pair of the component layout and undominated mask computed for mask j of the current layer are checked with the existing pairs of the current layer to determine if it is unique or not.We maintain the structure of the triples such that an entry can be accessed in O(1) time, indexed by the pair (lo, un) and the corresponding mask m for the previous and the current layer.

•
If it is unique, the triple value, consisting of the newly computed (lo, un) pair and its corresponding triple, consisting of the mask j, respective cardinality and the count, are added as a new triple for the current layer.

•
Consider that the current mask j produces the new pair (lo, un) with values s = s x and c = c x .
If the new pair is not unique, then there are three cases.Consider the existing entry of the (lo, un) pair and the corresponding j to have values s = s y and c = c y .
(a) If s y = s x , then c y ← c y + c x ; (b) If s y > s x , then s y ← s x ; c y ← c x ; (c) If s y < s x , then no update is required.

•
The above procedure is performed until the last layer, where the final solution is computed from the current layer information corresponding to the last layer.Of all the B k 2 k pairs for the current layer, a solution is considered to be feasible if the mask for the undominated vertices for any of the B k component layouts is 0, as this would mean all the vertices are dominated.The cardinality of MCD is the minimum value among all the feasible solutions.The count is then computed by considering each feasible entry with the minimum cardinality computed above and adding its corresponding count.

•
Thus, the solution and the corresponding count of optimal solutions for MCD problem are computed.
For the whole algorithm, we maintained a global structure, as mentioned above.It consisted of a maximum of O(B k 2 k ) entries corresponding to unique pairs of (lo, un) and another 2 k triples for each such pair.We maintainewa this information for only the previous and the current layers.So, the space used by the data structure is O(B k 2 2k ).This can be shown to be equal to O(n ), for any > 0, based on the proof for Lemma 1.This space requirement is in addition to the space required by the input graph which is O(nk).For k = O((log n) α ), O(nk) is the dominating term compared to O(n ).So, the space complexity is O(nk).The following is the proof for time complexity of the algorithm.
First, an expression for the runtime of the algorithm is derived.The initialization using the first layer takes O(k 2 2 k ) time.For each layer after the first, the 2 k masks of the current layer are combined with the B k 2 k pairs of the previous layer.For each pair, a current layer mask is combined with a maximum of 2 k masks of the previous layer that generated this pair.Checking the feasibility of a mask of the current layer takes O(k 2 ).Computing the new component layout and the new undominated mask takes O(k 2 ) each.The undominated mask is calculated for 2 k masks of the previous layer for each mask of the current layer.Accessing and updating an entry takes O(1) time, as mentioned above.This is done for O(n/k) layers.So, the time complexity expression can be written as If k = O(1), the time complexity becomes T = O(n).If we assume the worst case number of nodes in each layer, i.e., k = f (n), then the corresponding time complexity is T = O(n 1+ ). as shown below.
The running time of the algorithm is given by We know that the logarithmic functions grow slower than the polynomial functions.
Taking the log of both sides, we get Hence, we have proved our claim.
∴ 2 3(logn) α = O(n µ ) From above, we have We can write it as By arbitrarily taking small values for µ, δ and γ, can be any value, such that > 0.
Hence, the theorem is proved.
Theorem 5.The MCV Algorithm correctly computes a connected VC of minimum cardinality for LG k with a time complexity of O(n 1+ ) for any > 0 when k = O(log n) α and α < 1.The space complexity is O(nk).
Proof.The MCV Algorithm is similar to the MCD Algorithm.A mask, j, of layer i must be a valid VC for layer i.The check takes an additional O(k 2 ), though the total time complexity can be proved to be same as that of MCD.So, the proofs of correctness and time complexity follow from the proofs for the same of the MCD Algorithm.Hence, the time complexity is O(n 1+ ) for any > 0 when the number of vertices in each layer is k, where k = O((log n) α ) and α < 1.Similarly, the space complexity can be shown to be O(nk).
Lemma 2 proves that (log n)! is quasi-polynomial.Thus, if k = Θ(log n) then MCV and MCD are computed in quasi-polynomial time.Proving this is quite straightforward.By substituting (log n)! for k! into Equation (1) in Theorem 4, we get a product of a quasi-polynomial factor and a polynomial factor.Thus, the time complexity is quasi-polynomial.

Minor Enhancements
The current layer requires information only from the previous layer.So, only the variables of the current layer, i, and the previous layer, i − 1, are maintained.In the pseudocode shown for all algorithms, for simplicity, the variables of the current layer are stored at index 1 and the variables of the previous layer are stored at index 0 of the data structure sol.When the current layer, i, is completely processed, the variables from index 1 overwrite the corresponding variables in index 0.This can be avoided by alternating the index of current layer between indices 0 and 1, thereby reducing the execution time by a factor of O(1).
The optimum cardinalities for each of the problems are generated using minimal additional space.For example, the MVC Algorithm employs only O(k2 k ) space in addition to the space required by the graph.If, for each mask in each layer, we store the best compatible mask from the previous layer, then we can generate a solution.There are O(n/k) layers, each having O(2 k ) k-bit masks.This requires O(n2 k ) space instead of O(k2 k ) space.However, if we want to generate all solutions, then for each mask of a given layer, we need to store all compatible masks of its previous layer that yield the optimum value requiring O(n2 2k ) space.

Conclusions
A novel graph class called layered graphs was defined.It includes a subset of bipartite graphs and a subset of trees with n vertices.A layered graph can have exponential number of cycles.The typical restrictions like bipartiteness, planarity and acyclicity on graph classes that admit polynomial time solutions for hard problems are not applicable for this class.The known NP-complete problems were shown to be in class P for these graphs when the layer size is O(log | V |) for MIS, MVC and MDS, and O((log | V |) α ), where α < 1, for MCV and MCD.The count of the corresponding optimal solutions is also computed.We note that the identification of a maximum clique in a layered graph is direct as the inter-layer edges are limited to adjacent layers.Thus, one can independently solve q − 1 instances of the maximum clique problem on graphs induced by V i V i+1 (of size ≤ 2k, each in O(2 2k k 2 ) time) to obtain a maximum clique of LG n,q k .A few applications of layered graphs in computational molecular biology and social networks were addressed in this article.One can explore other problems that can be modeled by layered graphs.The design of larger graph classes (that include layered graphs as a sub-class) that admit polynomial time solutions for the problems studied in this article is an open problem.For example, in a layered graph, the inter-layer edges are restricted to the vertices of adjacent layers.If this restriction is dropped for O(1) edges originating from each layer, then one obtains a more general graph class.Such graphs can potentially model more scenarios than layered graphs.

Figure 2 .
Figure 2. MIS: Graph G consists of two layers, G 1 and G 2 .The same graph is employed for the illustration of other problems.The vertices of a maximum independent set are {b, e, f , h} from G 1 and {a, d, h} from G 2 .The cardinality of any MIS of G is 7.The vertices of MIS are shown in larger bold font.

Figure 3 .Figure 4 .
Figure 3. MVC: The vertices of a minimum vertex cover are {a, b, d, f , h} from G 1 and {a, c, d, e, h, i} from G 2 .The cardinality of any MVC of G is 11.The vertices of MVC are shown in larger bold font.

Figure 5 .
Figure 5. MDS: The vertices of a minimum dominating set are {a, d, f , h} from G 1 and {c, i} from G 2 .The cardinality of any MDS of G is 6.The vertices of MDS are shown in larger bold font.

Figure 6 .
Figure 6.MCD: The vertices of a minimum connected dominating set are {c, d, e, g, h} from G 1 and {b, c, d, e, f , i} from G 2 .The cardinality of any MCD of G is 11.The vertices of MCD are shown in larger bold font.

Theorem 1 .
The time complexities for MIS, MVC, and MDS are respectively O(nk2 2k ), O(nk2 2k ) and O(n2 3k ), where k = O(log n).When k = log n these time complexities yield O(n 3 k), O(n 3 k) and O(n 4 ) respectively.The space complexities are O(nk), O(nk) and O(k2 2k ) respectively.When k = log n these space complexities yield O(nk), O(nk) and O(kn 2 ) respectively.For MCV and MCD problems, the time complexity is O(n 1+ ) for any > 0, where the number of vertices in a layer is k = O((log n) α ) for α < 1.The space complexity is O(nk) for MCD and MCV.The time and space complexities of MVC and MCD are analyzed.The proofs of correctness for the remaining problems are similar.The time complexity for MDS was presented earlier.The MIS Algorithm correctly computes the MIS on LG n,q k .

Theorem 2 .
The MVC Algorithm correctly computes the MVC on LG n,q k .
If ∀ i G i is a connected component, then a single component layered graph, i.e., SLG, is obtained.•IfG is required to be a connected component, then a connected layered graph, i.e., CLG, is obtained.
1, i + 1}, then a linear layered graph, i.e., LLG, is obtained.LLG k denotes an LLG that is k-restricted.• 1, say A, and not covered in layer i, say B, can be computed in O(k 2 ).This needs to be computed only once.Subsequently, for each of the triples stored corresponding to l in layer i − 1, we need only to check if the undominated vertices are a subset of B in O(k) time.Thus, O(k2 k ) is the dominating term in the time complexity, yielding O(k2 2k ) for all masks in the previous layer.So, for all masks in the current layer, the time complexity is O(k2 3k ).