A Complete Characterization of all Magic Constants Arising from Distance Magic Graphs
Abstract
A positive integer is called a magic constant if there is a graph along with a bijective function from to first natural numbers such that the weight of the vertex for all . It is known that all odd positive integers greater equal and the integer powers of , , are magic constants. In this paper we characterise all positive integers which are magic constants.
Keywords: Magic constant, Distance magic graph, Algorithm.
AMS Subject Classification 2021: 05C 78.
1 Introduction
Throughout this article, we will assume that denotes the finite simple graph with denoting the set of vertices and the set of edges. For a vertex, , its neighborhood is given by . A positive integer is called a magic constant if there is a graph along with a bijective function such that the weight of the vertex , remains constant and equal to for all . Such labeling is called distance magic labeling. A graph equipped with distance magic labeling is known as a distance magic graph (for more details, see [1], [4]). We refer to West [13] for graph-theoretic terminology and notation not covered here.
Regardless of how the vertices are labeled, the magic constant remains invariant, as previously established [2, 10] i.e., it is independent of the distance magic labeling. At the International Workshop on Graph Labeling (IWOGL-2010), Arumugam [1] raised the question to characterise the set of positive integers, which are magic constants. Since then, this problem has captured the attention of researchers. The integers do not belong to the set of magic constants. On the other hand, all odd integers and all integers of the form are confirmed members of the set of magic constants (see, [7], [8]). A previous study in [14] identified a graph with vertices that possesses a magic constant of . However, characterising the set of integers, which are magic constants, is an ongoing problem in distance magic graphs. We have shown that positive integers of the form for and of the form for are magic constants. Hence, the remaining numbers are , and .
Bertault et al. [3] introduced a heuristic algorithm to identify various classes of labelings. Building on this, Fuad et al. [14] refined the algorithm, achieving the construction of all distance magic graphs up to isomorphism for orders up to . This is the well-known algorithm available for constructing distance magic graphs. However, from a computational point of view, this algorithm has limitations. It relies on a collection of all non-isomorphic graphs as input, a formidable task that poses challenges, particularly for higher-order graphs. Generating all non-isomorphic graphs of substantial sizes remains computationally demanding, thereby affecting the practicality of the algorithm.
In this paper, we completely solve the characterization problem of magic constants. We prove this result by providing constructions of distance magic graphs to obtain specific magic constants.
We have devised an algorithm to check if there is a distance magic graph for a given number of vertices and a specific magic constant . We have implemented this algorithm to construct magic graphs for , and . Our search for shows that no graph admits the magic constant . Using this algorithm, we have generated all distance magic graphs up to isomorphism of order up to . This enhances the existing collection of distance magic graphs [14].
This algorithm serves as a practical tool for researchers and enthusiasts in the field of distance magic graphs. Addressing the general challenge of characterizing all graphs possessing distance magic labelings using algorithms presents a computational hurdle. This is mainly due to the impracticality of generating all non-isomorphic graphs since this becomes increasingly unfeasible as the graph order grows. Consequently, the algorithms devised for characterisation problems often encounter limitations or become computationally intensive when dealing with graphs of larger vertices.
It is believed that for a given , only a small subset of the set of all graphs of order possess the distance magic property. Consequently, a different approach is required rather than providing a collection of non-isomorphic graphs as input and subsequently characterizing them for the distance magic property. Instead, the focus shifts towards developing algorithms capable of dynamically constructing all distance magic graphs on vertices. By adopting this strategy, we can bypass the challenge of generating all non-isomorphic graphs. We have successfully implemented this approach.
2 Main Results
The magic constant of regular distance magic graphs can be easily calculated, as shown in the following theorem.
Theorem 2.1.
It is known that each positive integer of the form is a magic constant of a graph union of copies of a -cycle as stated in the following theorem.
Theorem 2.2.
[6] A graph of order is a distance magic graph with magic constant if and only if , .
Figure 1 shows the distance magic labeling of with the magic constant .
The following result shows that each positive integer of the form is a magic constant of a graph .
Theorem 2.3.
[6] Let be a distance magic graph with magic constant . Then, the following are equivalent.
-
1.
.
-
2.
.
-
3.
Either is isomorphic to or contains exactly one copy of and all other components are isomorphic to .
Figure 2 shows the distance magic labeling of with magic constant .
From Theorem 2.2 and 2.3, we conclude that all odd positive integers are magic constants. This also answers the question: does belong to the set of magic constants, where is odd prime? (see [7]). As a special case of odd magic constants, we have found a direct construction for graphs with magic constant , where is an odd prime. We describe that next.
Proposition 2.4.
Given an odd prime , is a magic constant for all .
Proof.
Let be an odd prime. Then is of one of the following forms.
Case i. .
Then , for all and magic constant can be constructed by using copies of as given in Theorem 2.2.
Case ii. .
Then when is even and when is odd. When is even, we follow the argument as in case i above. Suppose is odd. If , we take , where . Hence, by the Theorem 2.3, .
Now, suppose . Consider a -regular graph on vertices. Then is a -regular graph on vertices. Therefore by Theorem 2.1, as required. ∎
Now, we explore the case of the even positive integers, which are magic constant.
When is an arbitrary graph with vertices , and is any graph with vertices, then by we denote the graph, which arises from by replacing each vertex by a copy of the graph with vertex set , and each edge by the edges of the complete bipartite graph with bipartition . The graph is then called lexicographic product or the composition of and .
In [9], the authors proved that for an -regular graph on vertices, the magic constant of is . With and , we obtain . This gives the proof of the following theorem.
Theorem 2.6.
For all , is a magic constant.
In [8], the authors proved that there exists a -regular distance magic graph of odd order if and only if . Now, we use this result to prove the existence of even magic constants of the form , .
Theorem 2.7.
For all , is a magic constant.
Proof.
Let be a -regular distance magic graph of odd order. Then, . By Theorem 2.1, the magic constant of such a graph is given by . If we write , where , then . This proves the theorem. ∎
We already know that the integers and are not magic constants [7], while and are magic constants (see, [7], [14]). Theorems 2.6 and 2.7 provide further insights into the nature of the set of magic constants. Theorem 2.6 reveals that all positive integers congruent to , with the exceptions of and , are the members of the set of magic constants. Meanwhile, Theorem 2.7 establishes that all positive integers greater than or equal to and congruent to are also in the set of magic constants.
As a result, the only remaining even positive integers requiring examination as magic constants are , and . We device an algorithmic approach to determine whether these integers qualify as magic constants of some graphs. Thus we have a complete characterisation of all magic constants (see Theorem 4.1).
3 An algorithm for constructing magic graphs and computing magic constants
Given positive integers and , our algorithm checks if there exists a graph with vertex set and a magic constant . We denote any such graphs as . Without loss of generality, we may assume that each vertex is labeled as for . The algorithm returns the first successful search if such a magic graph exists.
Let be the set of all subsets of the set with the sum of its elements equal to . For each , let . Note that if there exists a distance magic graph , then the neighborhood of a vertex , , must be a member of . Next, fix a neighborhood of a vertex , i.e., an element of , and construct a tree rooted at in the following manner. Add all elements in as children to . This is level . Add elements of as children to each node in level . This is level . Continue till we add all elements in to each node in level . Note that in level , each node of this tree is a possible candidate for a . Each branch of this tree gives an adjacency list for the vertices . These lists may or may not correspond to a graph. Whenever adjacency lists corresponding to a branch give a graph, we call such a branch a successful branch.
The algorithm consists of the following four steps:
3.1 Algorithm
-
Step 1.
Generate all subsets of the set that have the sum of its elements equal to .
-
Step 2.
For each , construct .
-
Step 3.
Construct a rooted tree with a root as a fixed element of .
-
Step 4
For a tree obtained in Step (), find a successful branch. Repeat Steps () and () for each element of until we find a successful branch, or we run out of elements in .
The approach described above is a brute force in some sense. For example, for the case , , there are more than branches to explore. We merge Step and Step to say Step () to optimise the search space as:
-
Step
We explore the branches of as discussed in Step and Step with the following condition. Let the tree be constructed till level and , . Next, while adding children to any of the we will check
(1) Also, at any moment,
(2)
Step () ensures symmetry, meaning that is adjacent to if and only if is adjacent to . If the condition stated in 1 or 2 is not met at any step, we avoid adding the corresponding node, preventing further growth of the tree below that node. This reduction strategy significantly reduces the size of the tree , leading to an exponential reduction in the search space.
3.2 Proof of correctness
It is sufficient to prove that every graph corresponds to a (successful) branch of some and each successful branch of each corresponds to some graph . It is easy to observe that if has a successful branch, then nodes on that branch constitute a graph .
Conversely, suppose there is a graph . Consider a tree rooted at . There is a one-to-one correspondence between branches of and the elements of the cartesian product . The neighborhood of each vertex , , is a member of . Hence, is an element of the cartesian product . Thus, it corresponds to some branch of .
3.3 Illustration
Let us illustrate these steps with an example. Let and . We know that there is only one graph up to isomorphism on vertices admitting magic constant [14]. All subsets of the set having sum are:
We have listed all the subsets as a list of lists for the proper indexing purpose in the pseudo-code. This completes Step . Next, we generate all possible neighborhood sets for each vertex as suggested in Step .
Now we construct a tree rooted at the node from . This makes . Add all the elements of the set as children to the root node as shown in Figure 3. The set of possible candidates for is
We have chosen , to maintain symmetry we must have . The only such element in is . Hence, we discard all other nodes in the level , and the tree won’t grow further below those nodes. Now we go to level . The set of possible candidates for is
So far we have and . Since , maintaining the condition given in (1) of Step . Then the only choices for are and . Without loss of generality consider . Now we go to level . The set of possible candidates for is
So far we have , and . Here hence but hence must contain . The only choice for is . We continue in a similar way, and lastly, we add pendants , , and from the set . For we discard the nodes and because for any and we must must have since hence maintaining symmetry condition as given in (1) of Step .
In Figure 3, we have illustrated a case of a successful branch (colored blue).
Now let us consider where we select the node instead of at level . In this case so far we have , and . Then we go to level . The set of possible candidates for is:
Since but , we must have but . The only such possibility is . We go to the next level . The set of possible candidates for is:
Since for any and each list in contains at least one of the numbers , in order to maintain the symmetry has no choices and we discard this branch. This discarded branch is shown in red color in Figure 3.

3.4 Graphs output with our algorithm
For a distance magic graph on vertices with distance magic labeling and magic constant , it is easily seen that [12]. For any vertex , . Hence, we have an upper bound . This bound is sharp (Figure 4 shows an example). Also, by definition of the distance magic graph, cannot be less than . Hence, we have and both the bounds are sharp. To check whether a given positive integer is a magic constant, we need to run the algorithm for each pair , where . Let be the smallest positive integer such that . Hence, running the algorithm for the pairs , where is sufficient. For example for , the possibilities for are . Further, we can omit a few values in some cases, as mentioned in (Chapter 2, [7]).
Our algorithm explores the possibility of being the magic constant for the graphs on a possible number of vertices . However, findings show that no graph admits the magic constant . On the other hand, multiple graphs admit as magic constants. As a representative example, we list one of the such graphs in Figure 5. It’s not practical to list all the non-isomorphic distance magic graphs of order up to due to their abundance (more than a thousand in number, see Table 1), we will list them of order up to . Also, the collection of distance magic graphs of order up to , generated using our algorithm is the same as the one given in [14] except for graphs of order . Hence, we list the distance magic graphs of order and only (see figures 6, 7).
number of vertices: | ||||||||||
number of non-isomorphic distance magic graphs |














3.5 Pseudo-code
For a given value of and , the Step of the algorithm involves the generation of all subsets of a set with sum . The algorithm may try all subsets of the given set in worst case. As a result, the time complexity of the above algorithm is exponential. However, our primary goal is to efficiently generate distance magic graphs only for specific values of and , so we do not place a strong emphasis on the time complexity of this algorithm.
We provide the complete pseudo-code for the algorithm.
4 Conclusions
With the results known earlier, and those proved in this paper, the magic constants are now completely characterized, as shown in the following theorem.
Theorem 4.1.
All positive integers except , and are magic constants.
Not all magic constants arise from connected graphs. Also, for some integers, for example, , there is a unique distance magic graph . This leads naturally to the following questions.
-
1.
Which magic constants are realised by connected distance magic graphs?
-
2.
For which pairs , there is unique distance magic graph on vertices with magic constant ?
Acknowledgement: The authors are grateful to Atharv Karandikar and Satyaprasad for their invaluable assistance in implementing the algorithm.
References
- [1] S. Arumugam, D. Froncek, and N. Kamatchi. Distance magic graphs—a survey. J. Indones. Math. Soc., (Special edition):11–26, 2011.
- [2] S. Arumugam, N. Kamatchi, and G. R. Vijayakumar. On the uniqueness of -vertex magic constant. Discuss. Math. Graph Theory, 34(2):279–286, 2014.
- [3] Bertault François, F. Raquel, M. Miller, P. Helmut, and V. Ehsan. A heuristic for magic and antimagic graph labellings. In Proc. VII Spanish Congress on Metaheuristics and Evolutive and Bioinspired Algorithms 2010, pages 677–684, 2010.
- [4] J. A. Gallian. A dynamic survey of graph labeling (25th edition). Electron. J. Combin., 5:Dynamic Survey 6, 43, 2022.
- [5] A. Godinho and T. Singh. Some distance magic graphs. AKCE Int. J. Graphs Comb., 15(1):1–6, 2018.
- [6] M. Jinnah. On -labelled graphs. In B.D. Acharya and S.M. Hedge, editors, Technical Proceedings of Group Discussion on Graph Labeling Problems, pages 71–77. NITK Surathkal, 1999.
- [7] N. Kamatchi. Distance Magic and Distance Antimagic Labelings of Graphs. Phd thesis, Kalasalingam Academy of Research and Education, Krishnankoil, Srivilliputhur, Tamil Nadu, June 2012.
- [8] P. Kovář, D. Fronček, and T. Kovářová. A note on 4-regular distance magic graphs. Australas. J. Combin., 54:127–132, 2012.
- [9] M. Miller, C. Rodger, and R. Simanjuntak. Distance magic labelings of graphs. Australas. J. Combin., 28:305–315, 2003.
- [10] A. O’Neal and P. J. Slater. Uniqueness of vertex magic constants. SIAM J. Discrete Math., 27(2):708–716, 2013.
- [11] S.B. Rao, T. Singh, and V. Parmeswaran. Some sigma labelled graphs i. In S. Arumugam, B.D. Acharya, and S.B. Rao, editors, Graphs, Combinatorics, Algorithms and Applications, pages 135–140. Narosa Publishing House, New Delhi, 2008.
- [12] V. Vilfred. -Labelled Graphs and Circulant Graphs. Phd thesis, University of Kerala, Trivandrum, Kerala, India, 1994.
- [13] D. B. West. Introduction to Graph Theory. Prentice Hall, 2nd edition, September 2000.
- [14] F. Yasin and R. Simanjuntak. A heuristic for distance magic labeling. Procedia Computer Science, 74:100–104, 2015. “The 2nd International Conference of Graph Theory and Information Security”.