Iran Journal of Computer Science

, Volume 1, Issue 3, pp 155–164

# Constraint programming models and population-based simulated annealing algorithm for finding graceful and $$\alpha$$-labeling of quadratic graphs

• Kourosh Eshghi
Original Article

## Abstract

In this research, a new mathematical integer programming model is presented for the graph labeling problem of quadratic graphs. The advantages of this model are linearity and the existence of an objective function. Furthermore, two constraint programming models and a meta-heuristics algorithm are also developed to generate feasible graceful labeling and $$\alpha$$-labeling for special classes of quadratic graphs. Experimental results on large sizes of graphs from the literature show the efficiency of the proposed model and approach.

## Keywords

Graph labeling Graceful labeling Mathematical programming Constraint programming Population-based simulated annealing

## 1 Introduction

In this paper, it is assumed that we have undirected graphs without loops or double connections between vertices. A graceful labeling of a simple graph $$G=(V, E)$$ is a one to one mapping $$\Psi$$ of a vertex set V(G) into the set $$\{0,1,2,\ldots , n\}$$ with the below property.

If defined for any edge $$e=\left\{ {u,v} \right\} \in E\left( G \right)$$, the value $$\varPsi ^{*}\left( e\right) =\left| {\varPsi \left( u \right) -\varPsi \left( V \right) } \right|$$ then $$\Psi ^{*}$$ is a one-to-one mapping of the set E(G) onto the set $$\{1, 2{\ldots }{\vert }E{\vert }\}$$ [1].

A graph with graceful labeling is called graceful graph.

An $$\alpha$$-labeling of a graph $$G=\left( {V,E} \right)$$ is a graceful labeling of G with the additional condition that: there exists a number $$\upgamma$$ such that, for any $$e\in E\left( G \right)$$ with end vertices $$u,v\in V\left( G \right)$$, $$\min \left\{ {\varPsi \left( v \right) ,\varPsi \left( v \right) } \right\} \le \gamma <\max \left\{ {\varPsi \left( v \right) ,\varPsi \left( v \right) } \right\}$$ [1].

Graceful and $$\alpha$$-labeling are the first labeling methods which were introduced in the late 1960s by Rosa [6]. It is obvious that if a graph has an $$\alpha$$-labeling, it is also graceful.

The computational complexity of this problem is not known, but some related problems, such as finding harmonious labeling in a graph, are in NP-class, but it is not known to be in P-class [2]. The problem of finding a graph is graceful or not can be shown mathematically in special classes of graphs but it is a tedious and difficult approach in many cases. A detailed survey in the field of graph labeling and its results can be found in an excellent survey by Gallian [2].

One of these classes is quadratic graphs. Quadratic graphs which are shown by $$Q\left( {m,n} \right)$$ or $$mC_n$$ are graphs with m. isomorphic 2-regular graphs that each component has n vertices [3].

Despite a large number of papers published on the subject of graph labeling in the literature, there are few particular techniques to be used by researchers to label graphs gracefully or by any other types of labeling. Furthermore, most approaches only applied to small size graphs with special structure. The following part of this context will provide an overview of the literature on this subject.

## 2 Literature review

As mentioned before, many attempts have been reported by researchers to find a graceful labeling in quadratic graphs.

Rosa in [6] proved that if G has an $$\alpha$$-labeling and if all vertices of G are of even degrees, then $$\left| {E\left( G \right) } \right| \equiv 0\left( {{ mod}~4} \right)$$ and G is bipartite. In [6] it is also proved that these conditions are also sufficient if G is a cycle.

Abraham and Kotzig in [7] proved that the graph $$C_{4a} \cup C_{4b}$$. has an graceful labeling for all $$a,b>0$$. One of the results of Abraham and Kotzig should be mentioned here: if G is a 2-regular graph on n vertices and n edges which has a graceful labeling $$\Psi$$, then there exists exactly one number $$v_x$$ ($$0<v_x <n$$.) such that $$\varPsi \left( v \right) \ne v_x$$ for all $$v\in V\left( G \right)$$. This number $$v_x$$. is referred as the missing value of the graceful labeling. Abraham and Kotzig in [7, 8] proved that missing value in quadratic graphs $$Q\left( {m,4k} \right)$$ is $$v_x =mk~or~3mk$$. Also in this research, they proved that if $$v_x =mk$$, then $$\gamma =2mk$$, else if $$v_x =3mk$$. then $$\gamma =2mk-1$$. Eshghi in his Ph.D. dissertation has shown that $$3C_{4k}$$ has $$\alpha$$-labeling for $$k > 1$$ [1]. One of the results of his research was to introduce the concept of standard labeling of graphs [1]. Lakshmi and Vangipuram in [9] proved that $$Q\left( {4,4k} \right)$$ is graceful. Eshghi also proved that $$5C_{4k}$$ has an labeling for all $$k\ge 1$$ [1]. He and Salarrezaei showed that $$7C_{4k}$$. has an $$\alpha$$-labeling for all $$k\ge 1$$ [5, 10].

As mentioned in the previous section, many papers have been published recently to show the existence of a special type of labeling for a particular class of graphs. Eshghi and Azimi used a mathematical programming models fording feasible $$\alpha$$-labeling in different classes of graphs [11, 12].

In [13], Redl presented mathematical and constraint programming models for finding graceful labeling in graphs. Smith and Puget in [14] have attempt to find graceful labeling in new classes of graphs by using constraint programming. Mahmoudzadeh and Eshghi presented an ant-colony algorithm for finding graceful labeling and $$\alpha$$-labeling for some special cases [15]. Eshghi and Salarrezaei have applied a tabu search algorithm for finding a feasible $$\alpha$$-labeling in quadratic graphs [4, 8].

## 3 Problem statement

All efforts in this research are focused on finding a feasible graceful or $$\alpha$$-labeling in quadratic graphs $$Q\left( {m,4k}\right) ,k\ge 1$$. Assumptions of the previous studies on this problem are mentioned below:
• It is clear that quadratic graphs are bipartite, so the vertices of the graph can be divided into two separate sets. If these sets are shown by X and Y, the members of these sets are placed one after each other. By considering an $$\alpha$$-labeling of $$Q\left( {m,4k} \right)$$, we have $$X\in \left\{ {0,1,2,\ldots ,\gamma } \right\}$$ and $$Y\in \left\{ {\gamma +1,\gamma +2,\ldots ,4mk} \right\}$$ so
• If $$v_x =mk\,;\gamma =2mk$$; then $$X\in \left\{ {0,1,2,\ldots ,2mk} \right\} -\left\{ {mk} \right\}$$ and $$Y\in \left\{ {2mk+1,2mk+2,\ldots ,4mk} \right\}$$.

• If $$v_x =3mk\,;\gamma =2mk-1;$$ then $$X\in \left\{ 0,1,2,\ldots ,2mk-1 \right\}$$. and $$Y\in \left\{ {2mk,2mk+2,\ldots ,4mk} \right\} -\left\{ {3mk} \right\}$$.

• In this research,, without loss of generality, we consider $$v_x =3mk;$$ therefore, $$\gamma =2mk-1$$: Due to the symmetrical structure of the problem, it is easy to show that in a quadratic graphs $$\left( {m,4k} \right) ,k\ge 1$$, graceful labeling with $$v_x =mk$$ and $$\gamma =2mk$$ is equivalent to the graceful labeling with $$v_x =3mk$$ and $$\gamma =2mk-1$$ [10]. By these assumptions, it is only needed to consider one of these cases in our models.

## 4 Mathematical model

In this part of the research, the proposed mathematical programming model for finding feasible graceful and $$\alpha$$-labeling in quadratic graphs are discussed.In this model, decision variables are defined as the labels of the vertices and edges. In Sect. 4.1, decision variables and terminologies will be explained.

### 4.1 Nomenclatures

The nomenclature was used to describe the proposed model as it is illustrated in this subsection.

Parameters

m

Number of connected components in $$Q\left( {m,4k} \right)$$

k

A quarter of the number of vertices in each component in $$Q\left( {m,4k} \right)$$

Integer nonnegative variables

The vertex label

$$x_i$$

$$x\in X$$

$$y_i$$

$$y\in Y$$

$$e_i$$

$$e\in E$$

0–1 variables

It is equal to 1 iff

$$\delta x_{1ij}$$

$$x_i >x_j$$

$$\delta x_{2ij}$$

$$x_i <x_j$$

$$tx_{ij}$$

$$x_i =x_j$$

$$\delta y_{1ij}$$

$$y_{i} >y_j$$

$$\delta y_{2ij}$$

$$y_i <y_j$$

$$ty_{ij}$$

$$y_i =y_j$$

$$\delta e_{1ij}$$

$$e_i >e_j$$

$$\delta e_{2ij}$$

$$e_i <e_j$$

$$te_{ij}$$

$$e_i =e_j$$

According to the mentioned assumptions, vertex labels are divided into two sets X and Y. The assignment of these variables to the edges and vertices of $$Q\left( {m,4k} \right)$$ graph is shown in Fig. 1. The cycles have been randomly named with numbers $$1,2,\ldots , m$$ and the decision variables are considered in this way. The vertex labels and edge labels in ith cycle are as follows:
 Vertex labels $$x_{2\left( {i-1} \right) k+1} ,y_{2\left( {i-1} \right) k+1} ,x_{2\left( {i-1} \right) k+2},$$ $$y_{2\left( {i-1} \right) k+2} ,\ldots ,x_{2\left( {i-1} \right) k+k} ,y_{2\left( {i-1} \right) k+k}$$ Edge labels $$e_{4\left( {i-1} \right) k+1} ,e_{4\left( {i-1}\right) k+2} ,\ldots ,e_{4\left( {i-1} \right) k+k}$$

### 4.2 Mathematical programming formulation for $$\alpha$$-labeling of Q(m, 4k)

The mixed integer mathematical programming formulation of graceful labeling and $$\alpha$$-labeling of quadratic graphs is as follows:
\begin{aligned}&\hbox {min}\,Z=\mathop \sum \limits _{{\begin{array}{l} {i=1} \\ {i\ne j} \\ \end{array} }}^{2mk} \mathop \sum \limits _{j=1}^{2mk} \left( {tx_{ij} +ty_{ij}}\right) +\mathop \sum \limits _{{\begin{array}{l} {j=1} \\ {j\ne i} \\ \end{array}}}^{4mk} \mathop \sum \limits _{i=1}^{4mk} te_{ij}, \end{aligned}
(1)
\begin{aligned}&S.t:\nonumber \\&e_{2i-1} =y_i -x_i \quad i=1,2,\ldots ,2mk \end{aligned}
(2)
\begin{aligned}&e_{2i} =y_i -x_{i+1}\nonumber \\&\quad i=1,2,\ldots ,2mk\;{\text {and}}\;i\ne 2k,4k,\ldots 2mk \end{aligned}
(3)
\begin{aligned}&e_{2i} =y_i -x_{i+1-2k}\quad i=2k,4k,\ldots 2mk \end{aligned}
(4)
\begin{aligned}&x_i \ge x_j -M_x \left( {1-tx_{ij} } \right) \quad i,j=1,2,\ldots ,2mk \end{aligned}
(5)
\begin{aligned}&x_i \le x_j +M_x \left( {1-tx_{ij} } \right) \quad i,j=1,2,\ldots ,2mk \end{aligned}
(6)
\begin{aligned}&x_i \ge x_j +\epsilon -M_x \left( {1-tx_{ij} } \right) \nonumber \\&\quad -M_x \left( {1-\delta x_{1ij} } \right) \quad i,j=1,2,\ldots ,2mk \end{aligned}
(7)
\begin{aligned}&x_i \le x_j -\epsilon +M_x \left( {1-tx_{ij} } \right) \nonumber \\&\quad +M_x \left( {1-\delta x_{2ij} } \right) \quad i,j=1,2,\ldots ,2mk \end{aligned}
(8)
\begin{aligned}&\delta x_{1ij} +\delta x_{2ij} =1\quad i,j=1,2,\ldots ,2mk \end{aligned}
(9)
\begin{aligned}&y_i \ge y_j -M_y \left( {1-ty_{ij} } \right) \quad i,j=1,2,\ldots ,2mk \end{aligned}
(10)
\begin{aligned}&y_i \le y_j +M_y \left( {1-ty_{ij} } \right) \quad i,j=1,2,\ldots ,2mk \end{aligned}
(11)
\begin{aligned}&y_i \ge y_j +\epsilon -M_y \left( {1-ty_{ij} } \right) \nonumber \\&\quad -M_y \left( {1-\delta y_{1ij} } \right) \quad i,j=1,2,\ldots ,2mk \end{aligned}
(12)
\begin{aligned}&y_i \le y_j -\epsilon +M_y \left( {1-ty_{ij} } \right) \nonumber \\&\quad +M_y \left( {1-\delta y_{2ij} } \right) \quad i,j=1,2,\ldots ,2mk \end{aligned}
(13)
\begin{aligned}&\delta y_{1ij} +\delta y_{2ij} =1\quad i,j=1,2,\ldots ,2mk \end{aligned}
(14)
\begin{aligned}&e_i \ge e_j -M_e \left( {1-te_{ij} } \right) \quad i,j=1,2,\ldots ,4mk \end{aligned}
(15)
\begin{aligned}&e_i \le e_j +M_e \left( {1-te_{ij} } \right) \quad i,j=1,2,\ldots ,4mk \end{aligned}
(16)
\begin{aligned}&e_i \ge e_j +\epsilon -M_e \left( {1-te_{ij} } \right) \nonumber \\&\quad -M_e \left( {1-\delta e_{1ij} } \right) \quad i,j=1,2,\ldots ,4mk \end{aligned}
(17)
\begin{aligned}&e_i \le e_j -\epsilon +M_e \left( {1-te_{ij} } \right) \nonumber \\&\quad +M_e \left( {1-\delta e_{2ij} } \right) \quad i,j=1,2,\ldots ,4mk \end{aligned}
(18)
\begin{aligned}&\delta e_{1ij} +\delta e_{2ij} =1\quad i,j=1,2,\ldots ,4mk \end{aligned}
(19)
\begin{aligned}&y_i -\mathop \sum \limits _{j=2mk}^{3mk-1} j.w_{i\left( {j+1} \right) } \nonumber \\&\quad +\mathop \sum \limits _{j=3mk+1}^{4mk} jw_{ij} =0\quad i=1,2,\ldots ,2mk \end{aligned}
(20)
\begin{aligned}&\mathop \sum \limits _{i=1}^{2mk} w_{ij} =1\quad j=2mk+1,\ldots ,4mk \end{aligned}
(21)
\begin{aligned}&1\le e_i \le 4mk\quad i=1,2,\ldots ,4mk \end{aligned}
(22)
\begin{aligned}&2mk\le y_i \le 4mk\quad i=1,2,\ldots ,2mk \end{aligned}
(23)
\begin{aligned}&0\le x_i \le 2mk-1\quad i=1,2,\ldots ,2mk \end{aligned}
(24)
\begin{aligned}&tx_{ij} ,ty_{ij} ,\delta x_{1ij} ,\delta x_{2ij} ,\delta y_{1ij} ,\delta y_{2ij} \nonumber \\&\quad =\left\{ {0,1} \right\} \quad i,j=1,2,\ldots ,2mk \end{aligned}
(25)
\begin{aligned}&te_{ij} ,\delta e_{1ij} ,\delta e_{2ij} ,w_{ij} =\left\{ {0,1} \right\} \quad i,j=1,2,\ldots ,4mk \end{aligned}
(26)
\begin{aligned}&x_i ,y_i \in Z\quad i=1,2,\ldots ,2mk \end{aligned}
(27)
\begin{aligned}&e_i \in Z\quad i=1,2,\ldots ,4mk. \end{aligned}
(28)
The objective function (1) is to minimize the repeated values in the vertex and edge labels. If the given graph is graceful, the objective function must be 0. Constraints (2)–(4) represent the relations between edge and vertex labels. Constraints (5)–(9) guarantee that the labels of vertices in X are not equal to each other. If some vertices accept equal labels, the related binary variables will be equal to 1, therefore, the cost function cannot be zero. Constraints (10)–(14) likewise ensure that the labels of vertices in Y are different with each other. Constraints (15)–(19) prevent producing of repeated numbers for edge labels. Constraints (20) and (21) consider $$v_x =3mk$$ . Although the existence of these constraints is not necessary in the proposed model, but it causes the elimination of some redundant labels. Constraints (22)–(28) determine the available ranges for decision variables. It should be noted that according to the model, constraints (27)–(28) can be omitted. Due to the minimum difference between two integer variables, it is considered that $$\epsilon =1$$. According to (6), it can be shown that $$\left| {x_i -x_j } \right| \le M_x$$, so the reasonable value for $$M_x$$ is 2mk. Also one of the results of the constraint (11) is $$\left| {y_i -y_j } \right| \le M_y$$. Note that $$\mathop {\min }\nolimits _i y_i =2mk$$ and $$\mathop {\max }\nolimits _i y_i =4mk$$, thus the suitable value for $$M_y$$ parameter is $$2mk+1,$$ and in the same way, it can be shown that $$M_e =4mk$$ is an appropriate assumption.

Note that in the proposed model parameters can be considered as $$\epsilon =1$$, $$M_x =2mk$$, $$M_y =2mk+1$$ and $$M_e =4m$$.

The number of constraints and variables in this mathematical model respectively are $$\left( {4mk\left( {4+15mk} \right) +1} \right)$$ and $$(120m^{2}k^{2}+8mk)$$, respectively.

## 5 Constraint programming model

Finding a graceful and $$\alpha$$-labeling in graphs can be considered as a feasibility problem. As it was shown in the literature, constraint programming technique approach is suitable in finding feasible solutions. In this part, two constraint programming models are presented to find a feasible graceful and $$\alpha$$-labeling for quadratic graphs.

### 5.1 The first constraint programming model

In this model, $$v_i ,e_i$$ and $$l_i$$ are decision variables that are used for modeling the problem so that $$v_i$$ determines the label of vertices in quadratic graphs. The first constraint programming model is as follows and e and $$l_i$$ indicate the value of edge labels and the location of ith edge label, respectively.
\begin{aligned}&S.t:\nonumber \\&e_i =|v_i -v_{i+1} |\quad i=1,2,\ldots ,4mk-1\nonumber \\&\qquad \qquad \qquad {\text {and}}\;mod\left( {i,4k} \right) \ne 0 \end{aligned}
(29)
\begin{aligned}&e_i =|v_i -v_{i+1-4k} |\quad i=4k,8k,\ldots ,4mk \end{aligned}
(30)
\begin{aligned}&v_i ,e_i ~are~all-different\quad i=1,2,\ldots ,4mk \end{aligned}
(31)
\begin{aligned}&inverse\left( {e,l} \right) \end{aligned}
(32)
\begin{aligned}&v_i \in \left\{ {0,1,2,\ldots ,4mk} \right\} -\left\{ {3mk} \right\} \quad i=1,2,\ldots ,4mk \end{aligned}
(33)
\begin{aligned}&e_{i,} l_i \in \left\{ {0,1,2,\ldots ,4mk} \right\} \quad i=1,2,\ldots ,4mk. \end{aligned}
(34)
Constraints (29) and (30) represent relations between the edge and vertex labels in quadratic graphs. Constraint (31) ensures that all variables of $$v_i$$ and $$e_i$$ are different from each other. Constraint (32) is added to the model due to a branching rule, we put in this model. According to the relations between the vertex and edge labels, a branching rule which considers $$v_i$$and $$e_i$$, simultaneously, cannot be defined constraints (33) and (34) prevent decision variables to obtain infeasible values. This model has $$\left( {12mk} \right)$$ variables and $$\left( {12mk+1} \right)$$ constraints.

### 5.2 The second constraint programming model

The functions used in constraint programming enable us to model the problem in different structure. In the second constraint programming model, decision variables are similar to the mathematical integer model presented in Sect. 4.2.
\begin{aligned}&S.t:\nonumber \\&e_{2i-1} =y_i -x_i\quad i=1,2,\ldots ,2mk \end{aligned}
(35)
\begin{aligned}&e_{2i} =y_i -x_{i+1} \quad i=1,2,\ldots ,2mk,i\ne 2k,4k,\ldots 2mk\nonumber \\ \end{aligned}
(36)
\begin{aligned}&e_{4i} =y_{2ik} -x_{2\left( {i-1} \right) k+1}\quad i=1,2,\ldots ,m \end{aligned}
(37)
\begin{aligned}&x_{2ik+1} \le x_{2jk+1} -1\quad 1\le i<j\le m-1 \end{aligned}
(38)
\begin{aligned}&x_{2ik+1} \le x_{2ik+j} \quad 1\le i\le m-1,2\le j\le 2k \end{aligned}
(39)
\begin{aligned}&x_{2ik} \le x_{2ik-1} -1\quad 2\le i\le m \end{aligned}
(40)
\begin{aligned}&x_i ,y_i ~are~all-different\quad i=1,2,\ldots ,2mk \end{aligned}
(41)
\begin{aligned}&e_i ~is~all-different\quad i=1,2,\ldots ,4mk \end{aligned}
(42)
\begin{aligned}&inverse\left( {e,l} \right) \end{aligned}
(43)
\begin{aligned}&x_i \in \left\{ {0,1,2,\ldots ,2mk-1} \right\} \quad i=1,2,\ldots ,2mk \end{aligned}
(44)
\begin{aligned}&y_i \in \left\{ {2mk,\ldots ,4mk} \right\} -\left\{ {3mk} \right\} \quad i=1,2,\ldots ,2mk \end{aligned}
(45)
\begin{aligned}&e_i ,l_i \in \left\{ {0,1,2,\ldots ,4mk} \right\} \quad i=1,2,\ldots ,4mk. \end{aligned}
(46)
In this model, constraints (35)–(37) are equal to (2)–(4) in mathematical integer programming model, respectively. The role of constraints (38)–(40) are similar to the constraints (20) and (21) in the mixed integer model. Constraints (41) and (42) ensure that all vertex and edge labels must be different from each other. Constraints (44)-(46) prevent decision variables to obtain infeasible values. Constraint (43) is equal to (32) in the previous model. This constraint replaces values of the components of array e with indices of array l. If we intend to model this constraint with mathematical integer model, $$inverse\left( {e,l} \right)$$ is equivalent to (47)–(51).
\begin{aligned}&e_j \ge i+\epsilon -M\left( {\gamma _{ji}^1 +\delta _{ij} } \right) \quad i,j=1,2,\ldots ,4mk \end{aligned}
(47)
\begin{aligned}&e_j \ge i-\epsilon +M\left( {\gamma _{ji}^2 +\delta _{ij} } \right) \quad i,j=1,2,\ldots ,4mk \end{aligned}
(48)
\begin{aligned}&l_j \ge j-M\left( {1-\delta _{ij} } \right) \quad i,j=1,2,\ldots ,4mk \end{aligned}
(49)
\begin{aligned}&l_j \le j+M\left( {1-\delta _{ij} } \right) \quad i,j=1,2,\ldots ,4mk \end{aligned}
(50)
\begin{aligned}&\gamma _{ji}^1 +\gamma _{ji}^2 =1\quad i,j=1,2,\ldots ,4mk. \end{aligned}
(51)
In a branch and bound procedure to solve the model, a branching rule is defined using constraints (47)–(51). The number of variables and constraints in this model, respectively, are $$\left( {12mk} \right)$$ and $$\left( {14mk+\frac{1}{2}\left( {m^{2}-3m+1} \right) -2k+1} \right)$$, respectively.

## 6 Population-based simulated annealing

Now, we want to solve the model by simulated annealing (SA). Simulated annealing was introduced by Scott Kirikpatrick [17]. At each step, the algorithm considers some neighbors of the current solution and probabilistically decides whether to move the system into a new state that is selected from neighbors of the current solution or to stay in the current solution. These probabilities ultimately lead the system to move into states of lower energy. Typically this step is repeated until the whole system reaches to a state that is good enough as a solution, or until a given computational stop criterion has been reached. According to this description, the strength of SA is in generating intensification. In order to have adequate diversification in the algorithm, the population aspect in the SA algorithm will be added. Consequently, the population based simulated annealing will be attained, which is called PBSA [16].

Reduce temperature function which is proposed is $$T\left( n\right) =\alpha \cdot T\left( {n-1} \right) , \quad 0<\alpha <1$$ [17].

Solution representation, objective function, neighborhood structure and stop criteria of our model will be described in the following subsections, respectively.

### 6.1 The solution representation

The performance in meta-heuristic algorithms depends significantly on the representation of the solution. In the proposed algorithm, vertex labels in quadratic graphs are represented in an array with the length of 4mk which it’s odd elements must be members of X and the even elements of this array must be members of Y. For instance, Fig. 2 shows the solution for the graph.

To calculate edge labels in graceful labeling with this representation, $$V_i$$ is defined to display vertex labels such that:
\begin{aligned}&V_{2i-1} =x_i \quad i=1,\ldots ,2mk \end{aligned}
(52)
\begin{aligned}&V_{2i} =y_i \quad i=1,\ldots ,2mk. \end{aligned}
(53)
Based on Eqs. (51) and (52), the relations between edge labels and vertex labels are defined as follows:
\begin{aligned}&e_i =|v_i -v_{i+1} |\quad i=1,2,\ldots ,4mk-1\nonumber \\&\quad \;{\text {and}}\;mod\left( {i,4k} \right) \ne 0 \end{aligned}
(54)
\begin{aligned}&e_i =|v_i -v_{i+1-4k} |\quad i=4k,8k,\ldots ,4mk \end{aligned}
(55)
According to these relations, for solving graceful labeling problem in quadratic graphs, a proposed objective function is presented in the next subsection.

### 6.2 The objective function

The accomplished calculations express that the utilization of probabilities is not pertinent in the objective function. Table 1, exhibits this fact. This table retells this point that the number of possible state for generating median labels is numerous.

Expected value of this probable distribution is $$E\left( i \right) =2mk+0.5$$. Therefore, the proposed objective function does not depend on the number of possible states for generating the edge labels. The objective function of PBSN will be shown in (56).
\begin{aligned} min~ f\left( x \right)= & {} \alpha \cdot t_E +\beta \cdot \mathop \sum \limits _{i=1}^{4mk} E_i^N \nonumber \\&+\,\rho \mathop \sum \limits _{i=1}^{4mk} \left| {2mk-E_i^N } \right| \cdot Cardinal\left( {E_i^N } \right) \end{aligned}
(56)
In (56), $$\alpha$$, $$\upbeta$$ and $$\uprho$$ are coefficients for improving objective functions that are considered 2mkmk and 2, respectively. $$E_i^N$$ is the edge label that PBSA has not generated yet. $$\vert E_i^N\vert$$ is the number of the edge labels and $$t_E$$ are the redundancies that are happened in the current solution.
Table 1

Edges probability distribution

Edge label

The number of possible states

Probability of edge labels equal to i

$$i\in \left\{ {1,\ldots ,mk} \right\}$$

i

$$\frac{i}{4m^{2}k^{2}}$$

$$i\in \left\{ {mk+1,\ldots ,2mk} \right\}$$

$$i-1$$

$$\frac{{i}-1}{4m^{2}k^{2}}$$

$$i\in \left\{ {2mk+1,\ldots ,3mk} \right\}$$

$$4mk-i$$

$$\frac{4mk-i}{4m^{2}k^{2}}$$

$$i\in \left\{ {3mk+1,\ldots ,4mk} \right\}$$

$$4mk-i+1$$

$$\frac{4mk-i+1}{4m^{2}k^{2}}$$

Table 2

Standard labeling for 4 component of $$mC_4k,m \ge 5$$

Standard labeling for 1st component

$$X=\left\{ {0,1,2,\ldots ,k-1,k+1,k+2,\ldots ,2k-1,2k} \right\}$$

$$Y=\left\{ {4mk-2k+1,4mk-2k+2,\ldots ,4mk-2,4mk-1,4mk} \right\}$$

Standard labeling for 2nd component

$$X=\left\{ {2mk-2k,2mk-2k+1,2mk-2k+2,\ldots ,2mk-1} \right\}$$

$$Y=\left\{ {2mk,2mk+1,2mk+2,\ldots ,2mk+k-1,2mk+k+1,2mk+k+2,\ldots ,2mk+2k-2,2mk+2k-1,2mk+2k} \right\}$$

Standard labeling for 3rd component

$$X=\left\{ {2mk-4k-1,2mk-4k,\ldots ,2mk-3k-3,2mk-3k-2,2mk-3k,2mk-3k+1,\ldots ,2mk-2k-2,2mk-2k-1} \right\}$$

$$Y=\left\{ {2mk+2k+1,2mk+2k+2,\ldots ,2mk+4k-2,2mk+4k-1,2mk+4k} \right\}$$

Standard labeling for 4th component

$$X=\left\{ {2k+1,2k+2,2k+3,\ldots ,4k-2,4k-1,4k} \right\}$$

$$Y=\left\{ {4mk-4k,4mk-4k+1,\ldots ,4mk-3k-2,4mk-3k-1,4mk-3k+1,4mk-3k+2,\ldots ,4mk-2k-2,4mk-2k\!-\!1,4mk-2k} \right\}$$

### 6.3 Neighborhood structure

In this section, several methods of finding neighbors are expressed:
• First policy: select X or Y or both of them. Then generate two numbers $$R_1$$ and $$R_2$$ such that $$0<R_1\;{\text {and}}\; R_2 <2mk$$. If X is selected, relocate $$x_{R_1}$$ with $$x_{R_2}$$ else if Y is chosen, relocate $$y_{R_1}$$ with $$y_{R_2}$$. If X and Y are selected, substitute $$x_{R_1}$$ by $$x_{R_2}$$ and substitute $$y_{R_1}$$ by $$y_{R_2}$$.

• Second policy: select X or Yor both of them. Then generate two numbers $$R_1$$ and $$R_2$$ such that $$0<R_1 \;{\text {and}}\; R_2 <2mk$$. If X is selected, values between $$x_{R_1}$$ and $$x_{R_2}$$ are reversed. If Y is selected, values between $$y_{R_1 }$$ and $$y_{R_2 }$$ are reversed. If X and Y are selected, reverse any value between $$x_{R_1 } \;{\text {and}}\; x_{R_2 }$$ and $$y_{R_1 }\, \& \, y_{R_2 }$$.

• Third policy: generate two random odd numbers $$i^{\prime }_1 ,i^{\prime }_2 :0<i^{\prime }_1 ,i^{\prime }_2 <4mk$$ such that $$i^{\prime }_1 <i^{\prime }_2$$ and move $$V_{i^{\prime }_1 +1}$$ and $$V_{i^{\prime }_1 +2}$$ to $$V_{i^{\prime }_2 +1}$$ and $$V_{i^{\prime }_2 +2}$$, respectively, or generate two random even numbers $$i^{\prime \prime }_1 ,i^{\prime \prime }_2 :0<i^{\prime \prime }_1 ,i^{\prime \prime }_2 <4mk$$ such that $$i^{\prime \prime }_1 <i^{\prime \prime }_2$$ and move $$V_{i^{\prime \prime }_1 +1}$$ and $$V_{i^{\prime \prime }_1 +2}$$ to $$V_{i^{\prime \prime }_2 +1}$$ and $$V_{i^{\prime \prime }_2 +2}$$, respectively.

### 6.4 Stopping criteria

The three stopping criteria for our algorithm are as follows:
1. 1.

Finding a feasible labeling.

2. 2.

Reaching the predetermined maximum number of iterations.

3. 3.

Reaching the time limit required by the algorithm.

The algorithm ends when it can reach to one of the above criteria.
Table 3

Time of experimental results of an integer mathematical model (s)

m

k

1

2

3

4

5

6

7

8

9

10

11

1

0.12

0.18

0.32

0.54

0.64

3.61

4.61

8.74

12

34

75

2

0.2

1.59

41

210

38

9.9

13

49

84

3

No

4

291

547

845

1067

4

2

25

273

874

1027

5

6.48

68

309

794

1074

6

41

82

412

815

1056

7

167

312

954

8

415

617

711

819

1074

9

317

1026

10

612

Table 4

Time of experimental results of the first constraint model (s)

m

k

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1

0.15

0.19

0.27

0.8

3

0.32

0.8

0.65

0.7

0.6

1.1

0.9

0.7

0.68

2

0.14

0.18

0.22

1.33

1.42

180

3

No

0.56

12

28

62

4

0.28

0.26

0.54

0.47

0.67

5

0.31

0.38

0.43

0.5

0.51

6

0.38

0.42

0.53

0.93

0.63

Table 5

Time of Experimental results of the second constraint model (s)

m

k

1

2

3

4

5

6

7

8

9

10

11

12

13

14

1

0.17

0.29

0.28

0.32

0.23

0.29

0.32

0.38

0.33

0.35

0.35

0.5

0.42

0.51

2

0.28

0.28

0.26

0.17

0.26

0.36

0.33

0.4

0.57

0.53

0.36

0.7

0.95

1

3

No

0.23

0.23

0.42

0.48

0.42

0.64

0.62

0.46

0.46

0.8

0.83

0.61

0.77

4

0.28

0.26

0.54

0.47

0.67

0.6

0.4

0.62

0.93

1

0.79

0.63

0.94

0.94

5

0.35

0.38

0.43

0.5

0.51

0.57

1.3

0.79

1

1.7

2

1.7

1.8

2

6

0.7

0.42

0.53

0.93

0.63

0.87

0.79

1.45

2.1

2.5

3

4.45

8.72

14

7

0.53

0.48

0.54

0.53

0.51

0.6

1.12

1.45

2.75

2

4.84

5.42

3.11

6.18

8

0.63

0.57

0.48

0.65

0.73

0.87

0.84

0.93

2.97

8.2

9

15.2

17

19

9

0.68

0.62

0.74

0.85

0.98

1.33

1.58

3.7

4.53

14

31

420

16.65

16.03

10

70

0.49

0.62

0.98

1.18

0.68

1.25

2.84

23

20

35

54

730

11

10

0.51

2.23

3.37

4.22

9.12

24

37

42

56

78

910

## 7 Computational experiments

The PBSA algorithm has been coded in MATLAB 2015b. The integer mathematical model and constraint programming models are coded in CPLEX 12.6. All computations were carried out on an Intel$$^{\circledR }$$740QM running at 1.73 GHz with up to 4GB of memory. The time limit for all the test instances in CPLEX was set to 1100 s and in MATLAB was 2700 s. The results are illustrated in Tables 2, 3, 4 and 5.

### 7.1 Improving approach

As mentioned in Sect. 2, Eshghi in [1] introduced standard labeling for quadratic graphs. With this concept, the investigated problems can be simplified and extended. It is assumed that 4 components of $$Q\left( {m,4k} \right) :m\ge 6\;{\text {and}}\; k\ge 3$$ have standard labelings which are illustrated in Table 2, so if corresponding decision variables are fixed, then the algorithm and models must find labeling for the rest ($$m-4$$) components of $$Q\left( {m,4k} \right)$$.

For improving the efficiency of constraint programming models, a branching rule has been used. This rule is chosen by testing all possible scenarios. Since the search is carried out in the space that is formed with variables xy and l, then the variables xy, and l are considered as independent variables and e as dependent.

Branching rule for independent variables are as follows:
• Branching rule on x variables: from the smallest to the largest indices, variables are selected for generating branches. Then, the branch that is assigned the least value will be selected.

• Then, the above procedure will be repeated for y and l variables, respectively.

### 7.2 Setting parameters

Running the proposed algorithm with the different parameters, but under the same circumstances showed that the best parameters of SA would be set to $$T_0 =100$$, $$\alpha =0.95$$ . The maximum iteration in interior and exterior loops depended on the graph size as describes in Table 6. Whenever random selection needed in algorithm, a roulette wheel approach used [18].

### 7.3 Numerical results

To evaluate the performance of models and algorithm of the studied problem, graceful and $$\alpha$$-labeling of the $$Q\left( {m,4k} \right)$$ for $$1\le m\le 11$$ and $$k\ge 1$$ is tested. Numerical results of an integer model are shown in Table 3. Also in Table 4 and Table 5 results of two constraint programming models are presented. Finally, in Table 7 the results of PBSA algorithms are illustrated.
Table 6

Time of experimental results of simulated annealing algorithm (s)

k

m

1

2

3

4

5

6

7

8

9

10

11

1

0.52

0.8

No

0.9

1.2

1.35

1.26

2.85

3.25

6.25

7.87

2

0.47

0.68

0.82

0.95

2.15

3.25

3.12

4.23

6.63

17.23

19

3

0.64

0.8

1.1

3.2

3.24

4.13

4.25

13.5

18

26

25

4

0.8

0.37

0.94

4.15

4.29

5.52

6.25

10

11

12.2

37

5

0.6

0.85

1

9.14

6.42

10.5

14

18

17

41

53

6

0.29

0.9

0.9

7.13

9.11

7.23

18

25

38

187

125

7

0.37

0.92

7

10

12

15

20

30

42

215

314

8

0.44

1.2

0.8

12

16.5

24

22

38

51

328

426

9

0.35

0.9

1.1

15

18

20

23

42

62

413

542

10

0.56

1.06

0.45

13

28

38

24

48

73

2325

723

11

0.71

3.7

2.1

16

25

42

51

62

97

543

685

12

0.74

0.82

1.17

12.5

27

53

62

81

108

948

1080

13

0.9

0.8

0.7

9.6

29

13

53

95

105

812

752

14

1

0.8

0.72

11

32

61

57

89

115

1910

1845

15

0.98

0.95

0.95

12

61

75

92

112

138

952

2025

16

1

1.24

8

19

48

82

97

310

423

1097

2214

17

0.63

1.7

14

24

53

93

107

415

535

1325

2025

18

1.1

2.11

18

31

67

65

105

416

576

1467

2460

19

2.21

3.1

23

37

82

83

113

572

750

1724

1152

20

1.1

6.52

29

42

93

74

128

590

819

1894

2712

21

0.95

9.27

17

41

104

112

138

617

1121

2305

2510

22

0.8

23

42

56

531

119

325

812

1960

2101

1142

23

0.85

42

58

114

286

138

428

923

1655

2411

2674

24

1.02

45

68

72

394

149

508

1070

2104

2684

25

1.56

48

81

95

423

153

519

1250

1940

2710

Table 7

Number of iteration in PBSA

Value of m or k

Number of maximum iteration

Number of maximum sub-iteration

$$1\le m\le 2\,{\text {and}}\, 1\le k\le 25~and~3\le m\le 11 \& \, 1\le k\le 2$$

200

50

$$3\le m\le 7\,{\text {and}}\, 3\le k\le 15$$

500

70

$$8\le m\le 11\,{\text {and}}\, 3\le k\le 15$$

1000

100

$$3\le m\le 11\,{\text {and}}\, 16\le k\le 21~and~ 3\le m\le 6\, \& \, 22\le k\le 25$$

2000

150

$$7\le m\le 11\,{\text {and}}\, 22\le k\le 25$$

5000

200

Numerical results in Table 3 show that the mathematical integer programming is able to label quadratic graphs with 160 vertices in a reasonable time. Numerical results in Tables 4 and 5 show that the constraint programming model is able to find a feasible $$\alpha$$-labeling for quadratic graphs with 526 vertices very fast.

Numerical results illustrate that the PBSA algorithm is able to labels quadratic graphs with 1012 vertices in a reasonable time.

Figure 3 shows that using the first constraint programming model, we are able to reach a feasible solution in the most cases of small size of quadratic graphs ($$m\le 7$$ and $$m \cdot k\le 9$$).

As mentioned in the Sect. 5, the number of variables in two proposed constraint programming models is equal to each other but the number of constraints in the second model is very greater than the one. However, the practical results shows that the second model is very effective model for $$\alpha$$-labeling of quadratic graphs with sizes greater than 40.
Figure 4 illustrates the fact that the second constraint programming is faster than the PBSA algorithm for finding $$\alpha$$-labeling and graceful labeling in median size quadratic graphs. Since the constraint programming models cannot find graph labeling in the large size graphs, using the populated-based simulated annealing is recommended.

The results of running our model and algorithm imply the following theorems.

### Theorem 1

All quadratic graphs $$Q\left( {m,4k} \right)$$ for $$1\le m\le 11$$ with less than 1000 vertices are graceful and have $$\alpha$$-labeling with the exception of $$3C_4$$.

### Theorem 2

$$Q\left( {12,4k} \right)$$ is graceful and has $$\alpha$$-labeling for $$1\le k\le 19$$.

### Theorem 3

$$Q\left( {13,4k} \right)$$ is graceful and has $$\alpha$$-labeling for $$1\le k\le 13$$.

The details of graceful labeling and $$\alpha$$-labeling of the above class of graphs are appeared in the appendix.

## 8 Conclusion

In this paper, one mathematical integer programming model and two constraint programming models were presented for finding $$\alpha$$-labeling and graceful labeling of quadratic graphs. According to our experimental results, for the small size quadratic graphs, both graceful labeling and $$\alpha$$-labeling can be found by using the mathematical programming and the first constraint programming model. For the median size quadratic graphs, the second constraint programming was suggested. Furthermore, a population-based simulated annealing algorithm was also developed to find a feasible solution for large size quadratic graphs.

For future study of this problem, design a hybrid algorithm using PBSA and constraint programming is suggested in this type of graphs.

## Supplementary material

42044_2018_12_MOESM1_ESM.pdf (429 kb)
Supplementary material 1 (pdf 429 KB)

## References

1. 1.
Eshghi, K.: Existence and construction of-labeling of 2-regular graphs with three components. PhD diss., Ph. D. thesis, University of Toronto (1997)Google Scholar
2. 2.
Gallian, J.A.: A dynamic survey of graph labeling. Electron. J. Comb., 20th edn. 1–415 (2017)Google Scholar
3. 3.
Eshghi, K.: Extension of $$\alpha$$-labelings of quadratic graphs. Int. J. Math. Math. Sci. 2004(11), 571–578 (2004)
4. 4.
Eshghi, K., Salarrezaie, M.: An integer programming model and a Tabu search algorithm to generate $$\alpha$$-labeling of special classes of quadratic graph. Iran. J. Oper. Res. (to appear)Google Scholar
5. 5.
Eshghi, K., Salarrezaie, M.: Existence and construction of $$\alpha$$-labeling for quadratic graph $$Q(7,4k)$$ and its extensions. Int. J. Graph. Theory Appl. (IJGTA) (to appear)Google Scholar
6. 6.
Rosa, A.: On certain valuations of the vertices of a graph. In: Theory of Graphs, International Symposium, Rome, pp. 349–355 (1966)Google Scholar
7. 7.
Abrham, J., Kotzig, A.: On the missing value in a graceful numbering of a 2-regular graph. Congr. Numer. 65(0988), 261–266 (1988)
8. 8.
Kotzig, A.: Decompositions of complete graphs into isomorphic cubes. J. Comb. Theory Ser. B 31(3), 292–296 (1981)
9. 9.
Lakshmi, D.R., Vangipuram, S.: A note on the graceful numbering of a class of trees. Def. Sci. J. 35, 65–70 (1985)
10. 10.
Salarrezaei, M.: Mathematical programming models for graceful labeling problem of 2-regular graphs. Master of Science thesis, Sharif University of Technology (2012)Google Scholar
11. 11.
Eshghi, K., Azimi, P.: Applications of mathematical programming in graceful labeling of graphs. J. Appl. Math. 1(1), 1–8 (2004)
12. 12.
Eshghi, K., Azimi, P.: An algorithm for finding a feasible solution of graph labeling problems. Utilitas Mathematica 72, 163–174 (2007)
13. 13.
Redl, T.A.: Graceful graphs and graceful labelings: two mathematical programming formulations and some other new results. Congressus Numerantium 164, 17–32 (2003)
14. 14.
Smith, B.M., Puget, J.-F.: Constraint models for graceful graphs. Constraints 15(1), 64–92 (2010)
15. 15.
Mahmoudzadeh, H., Eshghi, K.: Metaheuristic approach to the graceful labeling problem. Int. J. Appl. Metaheuristic Comput. IJAMC 1, 42–57 (2010)
16. 16.
Shaabani, H., Kamalabadi, I.N.: An efficient population-based simulated annealing algorithm for the multi-product multi-retailer perishable inventory routing problem. Comput. Ind. Eng. 99, 189–201 (2016)
17. 17.
Kirkpatrick, S., Gelatt, C.D., Vecchi, M.P.: Optimization by simulated annealing. Science 220(4598), 671–680 (1983)
18. 18.
Goldberg, D.E., Kalyanmoy, D.: A comparative analysis of selection schemes used in genetic algorithms. Found. Genet. Algorithms 1, 69–93 (1991)