Available online at www.sciencedirect.com
Electronic Notes in Discrete Mathematics 69 (2018) 101–108 www.elsevier.com/locate/endm
Modelling 3-Coloring of Outerplanar Graphs via Incremental Satisfiability Guillermo De Ita Luna, 1,2 Cristina L´opez Ram´ırez, 1,2 Meliza Gonz´alez Contreras 2 Fac. Cs. de la Computaci´ on, BUAP Puebla, M´exico
Abstract A novel method to model the problem of 3-coloring on outerplanar graphs is presented. The proposal is based on the specification of the logical constraints for the 3-coloring of an outerplanar graph in a dinaymic way, resulting in a polynomial-time instance of the incremental satisfiability problem. This proposal can be extended to consider other polynomial-time instances of the 3-coloring problem. Keywords: Incremental Satisfiability Problem, Graph Coloring, Outerplanar Graphs, 3-Coloring
1
Introduction
The graph vertex coloring problem consists of coloring the vertices of the graph with the smallest possible number of colors, so that two adjacent vertices can not receive the same color. If such a coloring with k colors exists, the graph 1 2
Thanks to SNI and Conacyt. Email:
[email protected],
[email protected],
[email protected]
https://doi.org/10.1016/j.endm.2018.07.014 1571-0653/© 2018 Elsevier B.V. All rights reserved.
102
G. De Ita Luna et al. / Electronic Notes in Discrete Mathematics 69 (2018) 101–108
is k-colorable. The chromatic number of a graph G, denoted as χ(G), represents the minimum number of colors for proper coloring G. The k-colorability problem consists of determining whether an input graph is k-colorable. The inherent computational complexity associated with solving NP-hard problems has motivated the search for alternative methods, which allow for some instances of NP-hard problems to be solved in polynomial time. For example, in the case of the vertex coloring problem, 2-coloring is solvable in polynomial time. Also, to determine the 3-colorability for AT-free graphs and for perfect graphs, as well as to determine χ(G) for some classes of graphs, such as: interval graphs, chordal graphs and comparability graphs [8]. In all those cases, special structures (patterns) have been found to characterize the classes of graphs that are colorable in polynomial-time complexity. Graph vertex coloring is an active field of research with many interesting subproblems. The graph coloring problem has many applications in areas like scheduling problems, frequency allocation, planning, etc [2,5,6]. We consider here a logical procedure to color outerplanar graphs. An outerplanar graph can be drawn as a polygonal chain. The polygonal chain graphs have been widely investigated, and they represent a relevant area of interest in mathematical chemistry, since they are molecular graphs used to represent the structural formula of chemical compounds [4,9,10]. In particular, hexagonal chains are the graph representations of an important subclass of benzenoid molecules, unbranched catacondensed benzenoid molecules, which play a distinguished role in the theoretical chemistry of benzenoid hydrocarbons [9]. The propensity of carbon atoms to form compounds, made of hexagonal arrays fused along the edges, motivated the study of chemical properties of hydrocarbons via hexagonal chains. On the other hand, SAT is an important theoretical problem representing the computational difficulty of the NP-complete class. Despite the theoretical hardness of SAT, current state-of-the-art decision procedures, known as SAT solvers, have become surprisingly efficient. Subsequently these solvers have been used for industrial applications. Such applications are rarely limited to solving just one decision problem, instead an application typically solves a sequence of related problems. Modern SAT solvers handle such problem sequences as an instance of the incremental satisfiability problem (ISAT) [11]. The ISAT problem is considered a dynamic incremental satisfiability problem, starting with an initial satisfiable formula F0 , and adding later on, new set of clauses: F1 , . . . , Fn . Each Fi results from a change in the preceding Fi−1 imposed by the ‘outside world’. Although the change can be a restriction (add clauses) or a relaxation (remove clauses), we will focus in the restriction case.
G. De Ita Luna et al. / Electronic Notes in Discrete Mathematics 69 (2018) 101–108
103
ISAT is of interest to a large variety of applications that need to be processed in an evolutive environment. For example, in applications as reactive scheduling and planning, dynamic combinatorial optimization, reviewing faults in combinatorial circuits, designing algorithms to coloring graphs, dynamic constraint satisfaction and machine learning in dynamic enviroments [7]. Both, SAT and 3-coloring have been shown to be hard problems (NPcomplete problems). We propose a novel greedy algorithm for the 3-coloring on outerplanar graphs. Our proposal is based on the logical specification of the constraints given by a 3-coloring of an outerplanar graph, forming then, a linear-time instance of the incremental satisfiability problem.
2
Preliminaries
Let G = (V, E) be an undirected simple graph (i.e. finite, loop-less and without multiple edges) with vertex set V (or V (G)) and set of edges E (or E(G)). Two vertices v and w are called adjacent if there is an edge {v, w} ∈ E, joining them. The Neighborhood of x ∈ V is N(x) = {y ∈ V : {x, y} ∈ E} and its closed neighborhood is N(x) ∪ {x} which is denoted by N[x]. We denote the cardinality of a set A, by |A|. The degree of a vertex x ∈ V , denoted by δ(x), is |N(x)|. The maximum degree of G, or just the degree of G, is Δ(G) = max{δ(x) : x ∈ V }. A path from a vertex v to w is a sequence of edges: v0 v1 , v1 v2 , . . . , vn−1 vn such that v = v0 , vn = w, vk is adjacent to vk+1 and the length of the path is n. A simple path is a path such that v0 , v1 , . . . , vn−1 , vn are all different. A cycle is just a nonempty path in which the first and last vertices are identical; and a simple cycle is a cycle in which no vertex is repeated, except the first and last vertices. A k-cycle is a cycle of length k (it has k edges). A cycle of odd length is called an odd cycle, while a cycle of even length is called an even cycle. A graph without cycles is called acyclic. Given a subset of vertices S ⊆ V , the subgraph of G where S is the set of vertices and the set of edges is {{u, v} ∈ E : u, v ∈ S}, is called the subgraph of G induced by S, and it is denoted by G|S. G − S denotes the graph G|(V − S). The subgraph induced by N(v) is denoted as H(v) = G|N(v), which contains all the vertices N(v) and all the edges that connect them. A coloring of a graph G = (V, E) is an assignment of colors to its vertices. A coloring is proper if adjacent vertices always have different colors. A kcoloring of G is a mapping from V into the set {1, 2, . . . , k} of k ‘’colors”. The k-colorability problem consists of deciding wheter an input graph is kcolorable. The chromatic number of G denoted by χ(G) is the minimum
104
G. De Ita Luna et al. / Electronic Notes in Discrete Mathematics 69 (2018) 101–108
value k such that G has a proper k-coloring. If χ(G) = k, then G is said to be k-chromatic or k-colorable. Let G = (V, E) be a graph. G is a bipartite graph if V can be partitioned into two subsets U1 and U2 , called partite sets, such that every edge of G joins a vertex of U1 to a vertex of U2 . If G = (V, E) is a k-chromatic graph, then it is possible to partition V into k independent sets V1 , V2 , ..., Vk , called color classes, but it is not possible to partition V into k − 1 independent sets.
3
Polygonal Graphs
Given an undirected connected graph G = (V, E), applying a depth-first search on G produces a tree graph TG , where V (TG ) = V (G). The edges in TG are called tree edges, whereas the edges in E(G)\E(TG ) are called frond edges. Let e ∈ E(G)\E(TG ) be a given frond edge. The endpoints of a cycle conform the frond edge of the cycle. The union of the path in TG between the endpoints of e with the edge e itself forms a simple cycle, it is called a basic (or fundamental) cycle of G with respect to TG . Let C = {C1 , C2 , ..., Ck } be the set of fundamental cycles found during a depth-first search on G. Given any pair of basic cycles Ci and Cj from C, if Ci and Cj share any edges they are called intersected cycles; otherwise they are called independent cycles. We say that a set of cycles is independent if no two cycles in the set are intersected. In particular, if two cycles share just one edge they are called adjacent. Let Ck be a simple cycle graph of length k. Ck is also called a polygon of size k. A polygonal chain Pk,t is a graph obtained by identifying a finite number of t polygons of size at least k, such that each polygon, except the first and the last one, is adjacent to exactly two polygons. When each polygon in Pk,t has the same number of k vertices, then Pk,t is a linear array of t k-gons. Let Pt = h1 h2 · · · ht be a polygonal chain with t polygons, where each hi and hi+1 have exactly one common edge ei , i = 1, 2, . . . , t − 1. A polygonal chain with at least two polygons has two end-polygons: h1 and ht . Meanwhile h2 , . . . , ht−1 are the internal polygons of the chain. In a polygonal chain, each vertex has degree either 2 or 3. The vertices of degree 3 are exactly the end points of the common edges between two consecutive polygons. If the array of polygons follows the structure of a tree where instead of nodes we have polygons, and any two consecutive polygons share exactly one edge, then we called that graph a polygonal tree[3]. An outerplanar graph Go could be redrawed in a planar way where any
G. De Ita Luna et al. / Electronic Notes in Discrete Mathematics 69 (2018) 101–108
105
pair of basic cycle are independent, or one of them is embedded into the other. Thus, Go is planar and all vertices are not enclosed by any edge. Generating a planar drawing is often viewed as a separate problem, in part because drawing algorithms tend to create a planar embedding as a first step, and in part because drawing can be application-dependent. In our case, we apply any of the linear-time procedures for redrawing an outerplanar graph as a polygonal array, for example, applying the Boyer’s algorithm [1]. Fixing a representation of an outerplanar graph Go as a polygonal array PG , we define an order on the frond edges appearing on PG . A frond edge is the common edge between two sequential polygons in PG . Let F r be the set of all frond edge from PG . An order on F r is inherited by the post-order given on the polygons forming PG .
4
Coloring an Outerplanar Graph
Let K be a conjunctive normal form (CF) and l be a literal, the reduction of K by l, denoted by K[l], is the formula generated by removing the clauses containing l from K (subsumption), and by removing l from the remaining clauses (unit resolution). The reduction K[s] where s is set of literals s = {l1 , l2 , . . . , lk } is defined by successively applying K[li ], li , i = 1, . . . , k. The reduction of K by l1 gives the formula K[l1 ], following a reduction of K[l1 ] by l2 , giving as a result K[l1 , l2 ] and so on. The process continues until K[s] = K[l1 , ..., lk ] is reached. In case that s = ∅ then K[s] = K. Let K be a CF and s a partial assignment of K. If a pair of contradictory unitary clauses is obtained while K[s] is being computed, then K is falsified by the assignment s. Addmore, during the computation of K[s], new unitary clauses {u} can be generated. The partial assignment s is extended by adding such unitary clauses found, that is, s = s ∪ {u}. So, K[s] can be again reduced using the new unitary clauses. This iterative process is called Unit P ropagation(K, s) that is abbreviated as UP (K, s). Applying UP (K, s) generates a new assignment s that extend to s, and a new subformula K formed by the clauses from K that are not satisfied by s . We denote the previous formula as K = UP (K, s). Notice that if s falsifies K then s could have complementary literals and K contains the null clause. And when s satisfies K, then K is empty. We present the codification of the 3-coloring of a graph as a satisfiability problem, based on the classic polynomial reduction from 3-coloring to a 3Satisfiable instance.
106
G. De Ita Luna et al. / Electronic Notes in Discrete Mathematics 69 (2018) 101–108
Lemma 1 3-Coloring is polynomial reducible to SAT(K ∧ φ), K a 2-CF, φ a 3-CF. Proof. Let G = (V, E) be a graph where n = |V |, m = |E|. We define the logical variables xv,c meaning that the vertex v ∈ V has assigned the color c ∈ {1, 2, 3}. For each vertex v ∈ V , 3 logical variables xv,1 , xv,2 , xv,3 are created. Therefore, there are 3 ∗ n Boolean variables in (K ∧ φ). We define first the constraints forming K. For every edge e = {u, v} ∈ E, u and v must be colored differently. This restriction is modeled by 3 binary clauses, in the following way: (xu,1 ∨ xv,1 ) ∧ (xu,2 ∨ xv,2 ) ∧ (xu,3 ∨ xv,3 ). There are 3 ∗ |E| binary clauses of this class. The other class of binary constraints allows to define the restriction that every vertex has not more than one color. This restriction is modeled by 3 binary clauses in the following way. For each vertex v ∈ V : (xv,1 ∨ xv,2 ) ∧ (xv,2 ∨ xv,3 ) ∧ (xv,3 ∨ xv,1 ). There are 3 ∗ |V | binary clauses for this class. Both sets of 3 ∗ (|V | + |E|) binary clauses form the 2-CF K. Notice that in this case, SAT(K) is not enough to determine a 3-coloring of G, since although K would be satisfiable, there is not a 3-coloring deducible from SAT(K). In order to build such 3-coloring instance, a 3-CF φ has to be formed by the clauses modelling the restriction that every vertex must be assigned at least one color. Then, for each vertex v ∈ V the following clause is generated: (xv,1 ∨ xv,2 ∨ xv,3 ). φ has |V | 3-clauses. Furthermore, each of the 3 ∗ n variables of v(K) has only one occurrence in φ. This reduction can be performed in polynomial time on the size n and m, since it consists of creating 3 ∗ (n + m) binary clauses and (n) 3-clauses for φ. Furthermore, G has a 3-Coloring if and only if (K ∧ φ) is satisfiable. 2 Given the set of contraints (K ∧φ), any 3-Sat solver requests an exponential time on the size |K ∪ φ| to determine a 3-coloring of Go . The character non-deterministic for the process of assigning a color to each vertex of Go is reflected in the exponential time requested to solve its respective 3-SAT instance. However, for special graph toplogies, as it is the case of outerplanar graphs, new constraints added to (K ∧ φ) are helpful to solve in polynomial time the new incremental satisfiable instance. In order to supply a deterministic character to the depth-first search, we define an order to visit the vertices. We start the search with the vertex v ∈ V of minimum degree, the following vertices visited must have the lowest degree first and minimum label, as second criterion whenever there are multiple possible vertices to visit. We denote this depth-first search as df s(G). Given G = df s(G), let TG be the spanning tree of G . Notice that V (TG ) = V (G). And let C = {C1 , C2 , ..., Ck } be the set of fundamental cycles found
G. De Ita Luna et al. / Electronic Notes in Discrete Mathematics 69 (2018) 101–108
107
during the df s(G). If G is an acyclic graph, then TG = G and C = ∅. If G is acyclic or contains only even cycles, then G is bipartite and it is proper colorable with only two basic colors, because the vertices in G can be colored by levels. This means that all vertices in the same level have the same color and the nodes of two sequential levels are colored with two alternating colors. Let Go be the outerplanar input graph, and let φ0 = (K ∧ φ) be its codification as a 3-CF. Let F r be the set of frond edges of Go , sorted as it was explained in section 3. From F r, new unitary clauses will be added to (K ∧φ). Thus, new unitary clauses fix a color for each end-vertex of a frond edge. Let xv,c be the logical variable that denotes that the vertex v has the color c ∈ {1, 2, 3}. Let T hree = {1, 2, 3} be the set containing the three possible colors. To each vertex v ∈ V (G) a set T abu(v) is associated. T abu(v) indicates the prohibited colors for the vertex v. In fact, T abu(v) contains the variables associated to the vertex v that have a false value, i.e. T abu(v) = {c : (xu,c ), and {u, v} ∈ E(G)}. Notice that |T abu(v)| < 2, ∀v ∈ V , because when |T abu(v)| = 2 the clause (xv,1 ∨ xv,2 ∨ xv,3 ) assigns a color to the vertex v. According to the order given to the frond edges in F r, each frond (u, v) is taken from F r and a color is assigned to the end-vertices u and v, if any of them has not already been colored. Algorithm 1 3-Coloring on Outerplanar Graphs. 1 Represent Go as a polygonal array. 2 Remove any vertex of degree at most two, as well as any acyclic subgraph from Go (these subgraphs can be colored at the end of the process). 3 While((F r = ∅) and (K = ∅)) { IF(u and v have already colored)then Continue /* consider next frond */ IF(u has already colored)then b = min{T res − T abu(v)}; Else IF(v has already colored) then a = min{T res − T abu(u)}; Else IF((T abu(v) == T abu(u)) == ∅)then {a = 1; b = 2} Else IF(T abu(u) = ∅)then {a = min{T res − T abu(u)}; T abu(v) = T abu(v) ∪ {a}}; Else IF(T abu(v) = ∅)then {b = min{T res − T abu(v)}; T abu(u) = T abu(u) ∪ {b}; a = min{T res − T abu(u)}}; 4 Let s = {(xu,a ), (xv,b )} be an assignment determining color to u, v 5 Apply K = UP (K, s); } 6 Recover the vertices removed in step 2, apply a 3-Coloring on such vertices, assigning them a different color to that of their neighbours.
108
5
G. De Ita Luna et al. / Electronic Notes in Discrete Mathematics 69 (2018) 101–108
Conclusions
We propose a novel method to model the problem of 3-coloring on outerplanar graphs. Our proposal is based on the specification of the logical constraints generated for a greedy algorithm for the 3-coloring of a graph. It results in a linear-time greedy algorithm that solves specific instances of the incremental satisfiability problem.
References [1] Boyer J.M., Myrvold W.J., On the Cutting Edge: Simplified O(n) Planarity by Edge Addition, Graph Algorithms and Applications, 8:3 (2004), pp. 241–273. [2] Byskov J.M., Exact Algorithms for graph colouring and exact satisfiability, Phd thesis, University of Aarbus, Denmark, 2005. [3] De Ita G., Marcial-Romero R., Lopez P., Gonzalez M., Linear-time Algorithms for Computing the Merrifield-Simmons Index on Polygonal Trees, MATCH Comm. in Math. and in Comp. Chemistry, 79:1 (2018), pp. 55–78. [4] Do¨sli´c T., Litz M.S., Matchings and Independent Sets in Polyphenylene Chains, MATCH Commun. Math. Comput. Chem, 67 (2012), pp. 313–330. [5] Dvo˜ra´k Z., Kr´ al D., Thomas R., Three-coloring triangle-free graphs on surfaces, Proc. 20th ACM-SIAM Symp. on Discrete Algorithms, (2009), pp.120-129. [6] Mertzios G.B., Spirakis P. G., Algorithms and Almost Tight Results for 3Colorability of Small Diameter Graphs, (2012), Technical report available at http://arxiv.org/pdf/1202.4665v2.pdf. [7] Mouhoub, M., Sadaoui, S., Systematic versus non systematic methods for solving incremental satisifiability, Int. J. on Artificial Inteligence Tools, 16:1 (2007), pp.543–551. [8] Stacho J., 3-Colouring AT-free graphs in polynomial time, Algorithms and Computation, LNCS, 6507 (2010), pp.144–155. [9] Shiu W.C., Extremal Hosoya index and Merrifield-Simmons index of hexagonal spiders, Discrete Applied Mathematics, 156 (2008), 2978–2985. [10] Wagner S., Gutman I., Maxima and minima of the Hosoya index and the Merrifield-Simmons index, Acta Applicandae Mathematicae, 112.3 (2010), 323–346. [11] Wieringa, S., Incremental Satisfiability Solving and its Applications, Ph.D. thesis, Dept. Comp. Sc. and Engineering, Alto University, (2014).