Distance magic labeling and two products of graphs

Let $G=(V,E)$ be a graph of order $n$. A distance magic labeling of $G$ is a bijection $\ell \colon V\rightarrow {1,...,n}$ for which there exists a positive integer $k$ such that $\sum_{x\in N(v)}\ell (x)=k$ for all $v\in V $, where $N(v)$ is the neighborhood of $v$. We introduce a natural subclass of distance magic graphs. For this class we show that it is closed for the direct product with regular graphs and closed as a second factor for lexicographic product with regular graphs. In addition, we characterize distance magic graphs among direct product of two cycles.


Introduction and Preliminaries
All graphs considered in this paper are simple finite graphs. We use V (G) for the vertex set and E(G) for the edge set of a graph G. The neighborhood N (x) (or more precisely N G (x), when needed) of a vertex x is the set of vertices adjacent to x, and the degree d(x) of x is |N (x)|, i.e. the size of the neighborhood of x. By C n we denote a cycle on n vertices.
Distance magic labeling (also called sigma labeling) of a graph G = (V (G), E(G)) of order n is a bijection : V → {1, . . . , n} with the property that there is a positive integer k (called magic constant) such that w(x) = y∈N G (x) (y) = k for every x ∈ V (G), where w(x) is the weight of x. If a graph G admits a distance magic labeling, then we say that G is a distance magic graph.
The concept of distance magic labeling of a graph has been motivated by the construction of magic squares. However, finding an r -regular distance magic labeling is equivalent to finding equalized incomplete tournament EIT(n, r ) [5]. In an equalized incomplete tournament EIT(n, r ) of n teams with r rounds, every team plays with exactly r other teams and the total strength of the opponents of each team is k. For a survey, we refer the reader to [1].
We recall three out of four standard graph products (see [6]). Let G and H be two graphs. All three, the Cartesian product G H , the lexicographic product G • H , and the direct product G × H are graphs with vertex set V (G) × V (H ). Two vertices (g, h) and (g , h ) are adjacent in: -G H if and only if either g = g and h is adjacent with h in H , or h = h and g is adjacent with g in G; -G • H if and only if either g is adjacent with g in G or g = g and h is adjacent For a fixed vertex g of G, the subgraph of any of the above products induced by the set The main topic of this paper is the direct product (that is known also by many other names, see [6]). It is the most natural graph product in the sense that each edge of G × H projects to an edge in both factors G and H . This is also the reason that many times this product is the most difficult to handle among (standard) products. Even the distance formula is very complicated with respect to other products (see [8]), and G × H does not need to be connected, even if both factors are. More precisely, G × H is connected if and only if both G and H are connected and at least one of them is non-bipartite [13].
The direct product is commutative, associative, and has attracted a lot of attention in the research community in last 50 years. Probably the biggest challenge (among all products) is the famous Hedetniemi's conjecture: This conjecture suggests that the chromatic number of the direct product depends only on the properties of one factor and not both. This is not so rare and also in this work we show that it is enough for one factor to be a distance magic graph with one additional property and then the product with any regular graph will result in a distance magic graph. More details about the direct product and products in general can be found in the book [6].
Some graphs which are distance magic among (some) products can be seen in [2,3,9,10]. The following product cycle and product related results were proved by Miller, Rodger, and Simanjuntak. Theorem 1.3 [9] The cycle C n of length n is a distance magic graph if and only if n = 4. Theorem 1.4 [9] Let G be an r -regular graph and C n the cycle of length n for r ≥ 1 and n ≥ 3. The lexicographic product G • C n admits a distance magic labeling if and only if n = 4.
In particular we have: Rao, Singh and Parameswaran characterized distance magic graphs among Cartesian products of cycles. Theorem 1.6 [10] The Cartesian product C n C m , n, m ≥ 3, is a distance magic graph if and only if n = m ≡ 2 (mod 4).
In the next section we introduce a natural subclass of distance magic graphs. For this class of graphs we were able to generalize Theorem 1.4 and show that it is closed for the direct product with regular graphs. In the last section we characterize distance magic graphs among direct products of cycles. In particular, we prove that a graph C m × C n is distance magic if and only if n = 4 or m = 4 or m, n ≡ 0 (mod 4)).

Balanced Distance Magic Graphs
In order to obtain a large class of graphs for which their direct product is distance magic we introduce a natural subclass of distance magic graphs.
A distance magic graph G with an even number of vertices is called balanced if there exists a bijection : V (G) → {1, . . . , |V (G)|} such that for every w ∈ V (G) the following holds: if u ∈ N (w) with (u) = i, then there exists v ∈ N (w), v = u, with (v) = |V (G)| + 1 − i . We call u the twin vertex of v and vice versa (we will also say that u and v are twin vertices, or shortly twins) and is called a balanced distance labeling. Hence a distance magic graph G is balanced if for any w ∈ V (G) either both or none of vertices u and v with labels (u) = i and (v) = |V (G)| + 1 − i are in the neighborhood of w. It also follows from the definition that twin vertices of a balanced distance magic graph cannot be adjacent and that It is somewhat surprising that the condition N G (u) = N G (v) plays an important role in finding the factorization of the direct product, see Chapter 8 of [6]. In particular, if a non-bipartite connected graph has no pairs of vertices with the property N G (u) = N G (v), then it is easier to find the prime factor decomposition. Similarly, such pairs generate very simple automorphisms of G and have been called unworthy in [14]. However in both above mentioned cases not all vertices need to have a twin vertex as in our case.
It is easy to see that a balanced distance magic graph is r -regular for some even r . Recall that the magic constant is r 2 (|V (G)| + 1) by Observation 1.1. Trivial examples of balanced distance magic graphs are empty graphs on even number of vertices. Not all distance magic graphs are balanced distance magic graphs. The smallest example is P 3 . More examples (regular graphs with an even number of vertices) will be presented in the next section.
The graph K 2n,2n , n ≥ 1, is balanced distance magic. To verify this let V (K 2n,2n ) = {v 1 , . . . , v 4n }. Assume that the vertices are enumerated in such a way that the sets It is easy to see that the labeling is the desired balanced distance magic labeling for n ≥ 2. In particular, for n = 1 note that K 2,2 is isomorphic to C 4 and consecutive vertices receive labels 1, 2, 4, 3. Also correspond to labels of a distance magic labeling of C 4 . It is not hard to verify that the labeling is a balanced distance magic labeling of G • C 4 . Using similar labeling we obtain a larger family of balanced distance magic graphs. Next we give another description of balanced distance magic graphs, which was implicitly used in above examples and will help in forthcoming proofs.

Proposition 2.1 Graph G is balanced distance magic if and only if G is regular, and V (G) can be partitioned in pairs
Proof Let G be a balanced distance magic graph. Twins generate a desired partition of V (G) for which N (u i ) = N (v i ) holds, since every vertex w ∈ V (G) has either both or none of vertices u i and v i in its neighborhood. Also G is regular since every vertex must have the same amount of twins in its neighborhood to obtain the same weight equal to the magic constant.
Conversely let G be regular, and V (G) can be partitioned in pairs for all x ∈ V (G). Hence G is balanced distance magic graph.

Theorem 2.2 Let G be a regular graph and H be a graph not isomorphic to K n where n is odd. Then G • H is a balanced distance magic graph if and only if H is a balanced distance magic graph.
Proof Let G be an r G -regular graph and H be a graph not isomorphic to K n for an odd n. Let first H be a balanced distance magic graph with the vertex set V (H ) = {h 1 , . . . , h t } and let ϕ defined by ϕ(h j ) = j be a balanced distance magic labeling of H (we can always enumerate the vertices in an appropriate way).
Conversely, let G • H be a balanced distance magic (and hence regular) graph. If H is an empty graph on even number of vertices, then it is balanced distance magic graph.
If H is not empty, then for each pair of twins (g 1 , h 1 ) and (g 2 , h 2 ) we have what means that g 1 = g 2 , i.e. (g 1 , h 1 ) and (g 2 , h 2 ) lie in the same H -layer g 1 H . In consequence and by the Proposition 2.1 H is balanced distance magic.
Note that in order to prove the equivalence in the above theorem we needed to exclude H as an empty graph with odd number of vertices. Namely, it is not hard to see that for positive integer k, C 4 • K 2k−1 is a balanced distance magic graph, but K 2k−1 is not (recall that by the definition an empty graph is balanced distance magic if it has an even order). As an example see the labeling of C 4 • K 3 in the table below, where rows and columns represent labeling of vertices in C 4 -layers and K 3 -layers, respectively (the latter ones refer to consecutive vertices of C 4 ). The situation is even more challenging when we turn to the direct product. If one factor, say H , is an empty graph, also the product G × H is an empty graph. Hence for any graph G on even number of vertices G × K 2k−1 is a balanced distance magic graph, while K 2k−1 is not. However, we can still obtain a result similar to Theorem 2.2. For this we need the following observations.  N H (b) for every (a, b) ∈ V (G × H ) and that twin vertices have the same neighborhood. Thus we derive

Lemma 2.3 Let G × H be a balanced distance magic graph and let (g, h) and (g , h ) with g = g and h = h be twin vertices for some balanced distance magic labeling. Then the labeling in which we exchange the labels of (g , h ) and (g , h) is also balanced distance magic labeling with (g, h) and (g , h) being twin vertices.
and we can exchange labelings of (g , h ) and (g , h). By Proposition 2.1, is still a balanced distance magic labeling with twin vertices (g, h) and (g , h).
This lemma has clearly a symmetric version if we exchange the labels of (g , h ) and (g, h ). (g, h 1 ) and (g, h 2 ) for some balanced distance magic labeling. The labeling in which we exchange the labels of (g, h 2 ) and (g , h 1 ) is balanced distance magic labeling with twins (g, h 1 ) and (g , h 1 ).  N G×H (g , h) and therefore N G (g) = N G (g ). Now as in the proof of Lemma 2.3 we have

Lemma 2.4 Let G × H be a balanced distance magic graph, and let (g, h) and (g , h) be twin vertices as well as
and we can exchange labels of (g, h 2 ) and (g , h 1 ). By Proposition 2.1, is still a balanced distance magic labeling with twin vertices (g, h 1 ) and (g , h 1 ). (g, h ) and (g , h ), g = g , for some balanced distance magic labeling. The labeling in which we exchange the labels of (g , h ) and (g , h ) is a balanced distance magic labeling where (g, h ) and (g , h ) are twin vertices. {(g, h ), (g , h )} are pairs of twin vertices for g = g . Hence N G×H (g, h) = N G×H (g , h) and N G×H (g, h ) = N G×H (g , h ) and therefore N G (g) = N G (g ) = N G (g ). One can observe that

Lemma 2.5 Let G × H be a balanced distance magic graph, and let (g, h) and (g , h) be twin vertices as well as
and we can exchange labels of (g , h ) and (g , h ). By Proposition 2.1, is still a balanced distance magic labeling with twin vertices (g, h ) and (g , h ).

Theorem 2.6 The direct product G × H is balanced distance magic if and only if one of the graphs G and H is balanced distance magic and the other one is regular.
Proof Assume first, without loss of generality, that G is regular and H is a balanced distance magic graph with V (H ) = {h 1 , . . . , h p }, where the suffix indicates the label of a balanced distance magic labeling of H . Thus for j ≤ p 2 , h p+1− j is the twin vertex of h j . Recall that H is r H -regular for an even r H . Let V (G) = {g 1 , . . . , g t }. Pairs Conversely, let G × H be a balanced distance magic graph (this implies that G × H is a regular graph and hence also both G and H are regular). There exists a balanced distance magic labeling : Claim There exists a balanced distance labeling of G × H such that one of the following is true: 1. There exists an H -layer g H , such that the twin vertex of any (g, h) ∈ g H lies in g H .

There exists a G-layer G h , such that the twin vertex of any (g, h) ∈ G h lies in G h .
If there exists an H -layer or a G-layer such that the twin vertex of any vertex in this layer also lies within this layer, then we are done. Hence assume that this is not the case, i.e. for every H -layer g H there exists a vertex (g, h) such that its twin vertex (g , h ) has the property g = g and for every G-layer G h there exists a vertex (g, h) such that its twin vertex (g , h ) has the property h = h.
We use Algorithm 1 to rearrange the labels of vertices in V (G × H ) in such a way that we either obtain an H -layer closed for twin vertices or we couple all H -layers, i.e. we find pairs of H -layers { g H, g H } with the property that the twin vertex of a vertex (g, h) ∈ g H lies in g H and is of the form (g , h). The latter case implies that all G-layers (and in particular one of them, say G h ) are closed for twins, and the claim is proved.
Step 2: If A = {g} for some g, then STOP, g H is closed under twin vertices. If A = ∅ then STOP, all the H -layers are matched in such a way that in any pair { g H, g H } for every vertex (g, h) its twin vertex is of the form (g , h). If |A| ≥ 2, then proceed to step 3.  1 ) and (g , h 1 ) are twin vertices. Go to step 5.
Step 5: While there exists a vertex (g, h 1 ) ∈ g H ∪ G h with the twin vertex (g , h 1 ), where g / ∈ {g, g }, use Lemma 2.5 to obtain a new labeling with twin vertices (g, h 1 ) and (g , h 1 ). Proceed to step 6.
Step 6: While there exists a pair of twin vertices (g, h 1 ) and (g, h 2 ) , if the vertices (g , h 1 ) and (g , h 2 ) are not twins, then use Lemma 2.5 in order to make them twins. Observe that after step 5, all the vertices in g H ∪ G h have their twins in g H ∪ G h .
Step 6 guarantees that each application of the Lemma 2.5 in step 7 in fact exchanges the twins of a vertex in g H and a vertex in G h .
Assume that some H -layer, say g H , is closed for twins. In particular for every pair of twins (g, h 1 ), (g, h 2 ) we have

and in consequence
thus by the Proposition 2.1, H is balanced distance magic.
In the case when some G-layer G h is closed for twins, we can prove in an analogous way that G is a balanced distance magic graph. j+1 } and operation on the first suffix is taken modulo m and on the second suffix modulo n. We also refer to the set of all vertices v i, j with fixed i as i-th row and with fixed j as j-th column.

Distance Magic Graphs C m × C n
We start with direct products of cycles that are not distance magic.
Proof By commutativity of the direct product we can assume that m ≡ 0 (mod 4) and n = 4. Assume that C m × C n is distance magic with some magic constant k, which means there is a distance magic labeling . Let us consider sum of the labels of the neighbors of v i+1, j+1 and v i+3, j+1 for any i ∈ {0, . . . , m − 1} and j ∈ {0, . . . , n − 1}, operations on indices taken modulo m and n, respectively: It implies that Repeating that procedure we obtain that for any natural number α.
It is well known that if a, b ∈ Z m and gcd(a, m) = gcd(b, m), then a and b generate the same subgroup of Z m , that is, a = b .
Since m ≡ 0 (mod 4) we have gcd(2, m) = gcd(4, m) and 2 ∈ 4 , which implies that there exists α such that 4α ≡ 2 (mod m). We deduce that Substituting j with j + 2 we obtain Thus for every i, j we have which leads to a contradiction, since n = 4 and is not a bijection.
Next we show that some of direct products of cycles are distance magic but not balanced distance magic. Used constructions are similar to those by Cichacz and Froncek in [4].
Obviously the labeling is a bijection from V (C m × C n ) to {1, . . . , mn}. It is also straightforward to see that k = 2mn + 2 is the magic constant. Hence is distance magic labeling.
However, is not balanced distance magic, as none of the cycles C m , C n is (see Theorem 1.3) and thus their product cannot be balanced distance magic due to Theorem 2.6.