Available online at www.sciencedirect.com
Electronic Notes in Discrete Mathematics 50 (2015) 127–132 www.elsevier.com/locate/endm
Weighted antimagic labeling: an algorithmic approach Mart´ın Matamala
1,2
DIM-CMM (UMI 2807 CNRS) Universidad de Chile Santiago, Chile
Jos´e Zamora
1,3
Departamento de Matem´ aticas Universidad Andres Bello Santiago, Chile
Abstract A graph G = (V, E) is weighted-k-antimagic if for each w : V → R, there is an injective function f : E→ {1, . . . , |E| + k} such that for each vertex u the following sums are all distinct: v:uv∈E f (uv) + w(u). When such a function f exists, it is called a (w, k)-antimagic labeling of G. A connected graph G is antimagic if it has a (w, 0)-antimagic labeling where w(u) = 0 for each u ∈ V . In this work, an algorithm is proposed that computes in polynomial time a (w, 0)antimagic labeling of the complete bipartite graph Km,n = (V, E), when 2 ≤ n ≤ m and m ≥ 3, for any function w : V → R. On the one hand, the existence of this labeling provides new support to a wellknown conjecture of Hartsfield and Ringel asserting that any connected graph with at least two edges is antimagic. More precisely, for each complete partite graph H, with H ∈ / {K1,m , K2,2 } we prove that any connected graph G containing H as an spanning subgraph is weighted-0-antimagic. Moreover, given a function w, a http://dx.doi.org/10.1016/j.endm.2015.07.022 1571-0653/© 2015 Elsevier B.V. All rights reserved.
128
M. Matamala, J. Zamora / Electronic Notes in Discrete Mathematics 50 (2015) 127–132
(w, 0)-antimagic labeling can be computed in polynomial time. On the other hand, the ideas used in the design of our algorithm allows us to give a short algorithmic proof of the following fact: each connected graph G on n vertices having a universal vertex is weighted-1-antimagic, unless G = K1,n−1 and n is even. Keywords: antimagic labeling, weighted antimagic labeling, algorithm.
1
Introduction
In this work we present an algorithmic approach to a well-known conjecture raised by Hartsfield and Ringel in [5], in the context of graphs. A connected graph with m edges and n vertices is antimagic if we can assign to each edge e a distinct number f (e) in {1, . . . , m} such that the following sums are all different: for each vertex u, e∈E(u) f (e), where E(u) is the set of edges incident to vertex u. Hartsfield and Ringel conjectured that every connected graph with at least two edges is antimagic. It is easy to see that a graph with n vertices and maximum degree n − 1 is antimagic. It is also easy to see that cycles and paths are antimagic. Less obvious, in [2] it was proved that the class of antimagic graphs contains every complete partite graph, but K2 , and every graph with n vertices and maximum degree n − 2. This latter result was improved in [12], where it was proved that every graph with n vertices and maximum degree at least n − 3 is antimagic as well. Cartesian products of various graphs, as path and cycles, have been also proved to be antimagic ([3,9,10]). In [2], it was also proved that there is a constant c such that any graph with n vertices and minimum degree at least c log n is antimagic. This result is obtained by applying Lov´asz’s Local Lemma and in fact shows the existence of a much more general kind of labeling which we discuss later. More recently, in [4], it was proved that regular bipartite graphs are antimagic. However, the conjecture is still open even for trees, where the best result, proved in [8], shows that trees with at most one vertex of degree two are antimagic. Among the strategies considered so far, in [6], the following related notion was considered. Given an integer k, a graph G = (V, E) is weighted-kantimagic if for any weight function w : V → R, there is an injective function 1
Partially supported by Basal program PBF 03 and N´ ucleo Milenio Informaci´on y Coordinaci´ on en Redes ICM/FIC RC130003. 2 Email:
[email protected] 3 Email:
[email protected]
M. Matamala, J. Zamora / Electronic Notes in Discrete Mathematics 50 (2015) 127–132
129
f : E → {1, . . . , |E|+k}, such that the following sums are all different: for each vertex u, w(u) + e∈E(u) f (e). Such a function f is called a (w, k)-antimagic labeling. Clearly, if a graph is weighted-0-antimagic, then it is antimagic. Though similar to the notion of antimagic graph, the study of weighted-kantimagic graphs is much more elusive. By instance, one can easily see that the complete bipartite graph K1,m is not weighted-0-antimagic. However, with a few exceptions, it is unknown whether paths or cycles are weighted-0antimagic. On the other hand, the proof given in [2] actually shows that there is a constant c such that every graph with n vertices and minimum degree at least c log n is weighted-0-antimagic. Besides this result, which cover a large family of graphs, only a few more families are known to be weighted-0-antimagic. By using the Combinatorial Nullstellensatz Theorem, in [6], it was proved that any graph on n vertices having a 2-factor with each cycle of length 3, is weighted-0-antimagic, if n = 3q , for some integer q. Later, in [7], this result was extended to any odd prime instead of 3. As not every graph is weighted-0-antimagic, it is natural to ask if there is a constant k such that every graph is weighted-k-antimagic. A partial answer to this question was given in [11] where it was shown that K1,m is weighted-2antimagic, and it is weighted-1-antimagic, when m is even. Moreover, it was also proved that a path on p vertices, with p prime, is weighted-1-antimagic. These proofs, besides requiring to establish elaborated combinatorial identities, are non-constructive as they are based on the Combinatorial Nullstellensatz Theorem [1]. In contrast with what has been done before for the weighted case, where most results are show only the existence of a labeling, in this work we provide an algorithmic perspective to this problem for the bipartite complete graph. We present an algorithm which we call Antimagic. Roughly speaking Antimagic stars with a labeling such that all the vertices in the same independent set of Km,n have different sums. Hence, repeated values occur at vertices in different independent sets. At each step the algorithm locally modifies its current labeling so as it eliminates at least one repetition and do not create any. By iterating this process, the algorithm eliminates all the repeated values and ends with a (w, 0)-antimagic labeling of Km,n . It is important to note that from the unweighted case, proved in [2], it is possible to deduce an algorithm but this algorithm does not always work in the weighted case. For the sake of clarity, we present our algorithm in the language of matrices. Let [m] denote the set {1, . . . , m}, for m ∈ N. It is clear that there is a oneto-one correspondence between edge labeling of Km,n using integers in [mn]
130
M. Matamala, J. Zamora / Electronic Notes in Discrete Mathematics 50 (2015) 127–132
and m × n matrices filled with integers in [mn]. We say that a vector a ∈ Rm is non-decreasing if a1 ≤ · · · ≤ am . Given a ∈ Rm and b ∈ Rn be two nona decreasing vectors, we define the vectors r (A) ∈ Rm and cb (A) ∈ Rn by ra (A)i = ai + j∈[n] Aij and cb (A)j = bj + i∈[n] Aij . We call a matrix A an (a, b)-antimagic matrix if the corresponding bipartite complete graph Km,n has a (w, 0)-antimagic labeling where w is the function induced by a and b on the vertices. Let A be a matrix and let d = (s, t) ∈ [m] × [n]. Given a ∈ Rm and b ∈ Rn , we say that d is a collision if ra (A)s = cb (A)t . If s < m, then the matrix obtained from A by interchanging its values at positions d and d + er , where er = (1, 0), is called a row flip of A at d and it is denoted by r-flip(A, d). Similarly, if t < n, then the matrix obtained from A by interchanging its values at positions d and d + ec , where ec = (0, 1), is called a column flip of A at d and it is denoted by c-flip(A, d). We use these operations in the following algorithm: Algorithm 1 Antimagic Require: Two non-decreasing vectors a ∈ Rm and b ∈ Rn , 3 ≤ n ≤ m. Ensure: A – an (a, b)-antimagic matrix. Initialization: A(i, j) = (i − 1)n + j, for each (i, j) ∈ [m] × [n]. while A has a collision do find d = (s, t) the smallest, w.r.t. ≤2 , collision if s < m and t < n if ra (A)s+1 ≤ cb (A)t+1 then A ← r-flip(A, d). else A ← c-flip(A, d). else if s < m and t = n, then A ← r-flip(A, d). else if s = m and t < n, then A ← c-flip(A, d). else if ra (A)m−1 ≤ cb (A)n−1 then A ← c-flip(A, d − ec ) else A ← r-flip(A, d − er ). end while return A Theorem 1.1 For each 3 ≤ n ≤ m, algorithm Antimagic on input a ∈ Rm and b ∈ Rn , two non-decreasing vectors, runs in time O(nm) and returns an (a, b)-antimagic matrix. In Figure 1 we show an example of the algorithm. From the graph theoretical point of view, the correctness of our algorithm implies that every complete bipartite graph with the adequate size is weighted-
M. Matamala, J. Zamora / Electronic Notes in Discrete Mathematics 50 (2015) 127–132
131
Fig. 1. Five iteration of algorithm Antimagic. The input vectors are a = (126, 126, 126, 126, 126, 126) and b = (0, 30, 35, 126, 140, 161, 252). The initial matrix has five collision: (1, 1), (2, 3), (4, 4), (5, 6) and (7, 7). The (a, b)-antimagic matrix is obtained by applying c-flips at (1, 1) and (4, 4), and r-flips at (2, 3), (5, 6) and (6, 7).
0-antimagic. At the best of our knowledge, this result is new. Corollary 1.2 Given two integers n, m with 3 ≤ n ≤ m, the complete bipartite graph Km,n is weighted-0-antimagic. Moreover, given a function w a (w, 0)-antimagic labeling can be computed in polynomial time. For the sake of completeness we mention that we also have proved that K2,m is weighted-0-antimagic, but by using a different algorithm. Hence, the result is tight as K1,m and K2,2 are not weighted-0-antimagic. In [11], the authors noticed that if a graph contains a weighted-k-antimagic spanning subgraph,then it is weighted-k-antimagic as well. From this, it follows that a large class of graphs are weighted-0-antimagic, thus antimagic. In fact, we also prove the following result: Corollary 1.3 Let H be an arbitrary complete partite graph with at least five vertices and H = K1,m . Then, any graph containing H as a spanning subgraph is weighted-0-antimagic. Moreover, given a weight function w, a (w, 0)-antimagic labeling can be computed in polynomial time. The ideas used in the design of our algorithm allow us to give a short algorithmic proof of a generalization of the previously cited result about graphs having universal vertices [11]. More precisely, our result clarifies how far from
132
M. Matamala, J. Zamora / Electronic Notes in Discrete Mathematics 50 (2015) 127–132
being weighted-0-antimagic the graph K1,m is, by given a complete characterization of those weights for which a (w, 0)-antimagic labeling does not exist. This information allows us to prove the following: Theorem 1.4 Each graph G on n vertices having a universal vertex is weighted1-antimagic, unless G = K1,n−1 and n is even. Moreover, given a weight function w, a (w, 1)-antimagic labeling can be constructed in polynomial time.
References [1] N. Alon, Combinatorial Nullstellensatz, Probab Comput 8 (1999), 7-29. [2] N. Alon, G. Kaplan, A. Lev, Y. Roditty and R. Yuster, Dense graphs are antimagic, Journal of Graph Theory (2004), 47(4) 297-309. [3] Y. Cheng, Lattice grids and prims are antimagic, Theoretical Computer Science (2007), 374 (1-3) 66-73. [4] D.W. Cranston, Regular bipartite graphs are antimagic. Journal of Graph Theory (2009), 60 (3), 173-182. [5] N. Hartsfield and G. Ringel, Pearls in Graph Theory, Academic Press, Inc., Boston, 1990, pp. 108-109. [6] D. Hefetz, Antimagic graphs via the Combinatorial Nullstellensatz, Journal of Graph Theory (2005), 50(4) 263-274. [7] D. Hefetz, A. Saluz, and H. T. T. Tran, An Application of the Combinatorial Nullstellensatz to a Graph Labelling Problem, Journal of Graph Theory (2010), 65(1) 70-82. [8] G. Kaplan, A. Lev and Y. Roddity, On zero-sum partitions and anti-magic trees, Discrete Mathematics (2009), 309, 2010-2014. [9] T.-M Wang, Toroidal grids are antimagic, in: L. Wang (Ed.), Computing and Combinatorics, in: Lecture Notes in Computer Science (2005), vol 3595, Springer, 671-679. [10] T.-M Wang and C.-C Hsiao, On antimagic labeling for graph products, Discrete Mathematics (2008), 308 (16) 3624-3633. [11] T.-L. Wong and X. Zhu, Antimagic labelling of vertex weighted graphs, Journal of Graph Theory (2012), 70(3), 348-359. [12] Z. Yilma, Antimagic Properties of Graphs with Large Maximum Degree, Journal of Graph Theory (2013), 72(4), 367-373.