A positive integer is called a magic constant if there is a graph along with a bijective function from to the first natural numbers such that the weight of the vertex for all . It is known that all odd positive integers greater than or equal to and the integer powers of , , , are magic constants. In this paper, we characterize all positive integers that are magic constants and generate all distance magic graphs, up to isomorphism, of order up to .
Throughout this article, we assume that graph is a 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[15] for graph-theoretic
terminology and not ation not covered here.
Regardless of how the vertices are labeled, the magic constant, if it
exists, remains invariant (see [2,11]); that is, it is independent of
the distance magic labeling. At the International Workshop on Graph
Labeling (IWOGL-2010), Arumugam [1] raised the question to
characterize the set of positive integers, that 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 [16] identified a graph
with vertices that admits the
magic constant , and it is
straightforward to verify that
is the magic constant for the wheel graph [7]. However, characterizing 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.
[16] 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, it is heuristic, and 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 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 and implemented a backtracking algorithm to check if
there is a distance magic graph for a given number of vertices and a specific magic constant . Our algorithm is deterministic, and it
explores all the possible solutions in a robust manner. We have
implemented this algorithm to construct magic graphs for and . Our search for shows that no graph admits the
magic constant . Additionally,
with this algorithm, we have generated all distance magic graphs (up to
isomorphism) of order up to (see
Table 1). This enhances the existing
collection of distance magic graphs given in [16]. In particular, we find a new sixth
graph of order , adding to the
list of such graphs given in
[16].
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 characterization 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 possesses 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
Let be a graph. A subset of the vertex set of is said to be a dominating set
if there is a function , called dominating function, such that , and for each
vertex , . The
domination number of a graph is given by where . There is another variation of domination called
fractional domination.
Definition 2.1. A function
is called a total dominating function of the graph if for all . The fractional total domination number of a graph
is denoted by and is given by where .
This concept of a fractional domination number has a close relation
with the magic constant of a graph as stated in the following
theorem.
Theorem 2.2. [2,10] If a graph is distance magic, then its distance
magic constant .
Theorem 2.3. [6,9,13,14] Let be a distance magic graph on vertices. If is distance magic with distance magic
labeling and magic constant then .
Corollary 2.4. If is an -regular distance magic graph on vertices with magic constant , then .
Theorem 2.5. [8] There exists a -regular distance magic graph on an odd
number of vertices if and only if
.
Figure 1 A distance magic labeling of
It is known that a -regular
graph is distance magic if and
only if it is a disjoint union of copies of cycle [6]. Further, 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.6. [6] A graph of order is a distance magic graph with magic
constant if and only if
, .
The following result shows that each positive integer of the form
is a magic constant of a graph
.
Theorem 2.7. [6] Let be a magic distance graph with magic
constant . Then, the following are
equivalent.
.
.
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 .
Figure 2 A distance magic labeling of
From Theorems 2.6 and 2.7, 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]).
Now, we explore the case of the even positive integers, which are
magic constants.
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 .
Theorem 2.8. [5,9]
If is an -regular graph, then is distance magic for
any even .
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.9. 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.10. For all , is a magic constant.
Proof. Let be a -regular distance magic graph of odd
order. Then, . By
Corollary 2.4, the magic constant of this graph is given by . If we
write , where , then . This proves the theorem.
Theorem 2.11. No regular graph admits magic
constant .
Proof. We know that, if is a magic constant of an -regular graph on vertices then by Corollary 2.4,
and . This implies . Since is an integer, we have , or . Since is -regular graph on vertices, we must have . Therefore, we discard the
possibilities and . With we get . Therefore, by Theorem 2.5, is not possible, and hence we discard
this possibility. There cannot be -regular distance magic graph on vertices. Therefore, we discard the
case . Recall that, if then is union of disjoint copies of . Hence, by Theorem 2.6, the magic
constant . But
and . Therefore, we
discard the case . This
completes the proof.
We already know that the integers and are not
magic constants [7],
while , [7], and [16] are magic constants, as shown in
Figures 3, 6, 8, respectively. Also, we will
see in Section 3 that these distance magic graphs can
also be generated using our algorithm with the given magic constants.
Theorems 2.9 and 2.10 provide
further insights into the nature of the set of magic constants. Theorem
2.9 reveals that all positive integers
congruent to , with the
exceptions of and , are the members of the set of magic
constants. Meanwhile, Theorem 2.10 establishes that all positive
integers greater than or equal to and congruent to are also in the set of magic
constants.
Figure 3 Distance magic graph with magic constant
As a result, the only remaining even positive integers requiring
examination as magic constants are , , and . We devise an algorithmic approach to
determine whether these integers qualify as magic constants of some
graphs. Thus, we obtain a complete characterization of all magic
constants (see Theorem 5.1).
Consider the following example given in [12]: If the generalized Myclielskian of
the complete bipartite graph is distance magic, then
by Theorem 2.2, its magic constant is given by
. When ,
then , which is an integer,
but and is not distance magic. On the
other hand, for the case where and , is an integer and is distance magic. When
is not an integer, Theorem 2.2 implies that is not distance magic. However, when
is an integer may or may not be distance magic.
Therefore, it is noteworthy that given a graph and the exact value of , one can compute the value
of (the magic constant) , but it
is not possible to decide whether the underlying graph is distance magic or not using Theorem
2.2. Even if the fraction is an
integer, the graph may or may not
be distance magic.
The algorithm that we describe below is a natural way to construct
distance magic graphs, and it has been adopted previously for smaller
order graphs (see Chapter 2, [7]). Here, we give a general and robust
version of the same.
3. A backtracking algorithm for generating distance magic
graphs and magic constants
Given positive integers and
, our algorithm checks if there
exists a distance magic graph with vertex set and a magic constant
. We denote 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 distance 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
, , is a member of . Next, fix a neighborhood of a
vertex , that is, an element of
, and construct a tree rooted
at in the following manner. At
level , we have only the root
node. Add all elements in
as children to . This is level
. Add elements of as children to each node in level
. This is level . Continue until we add all elements in
to each node in level . Note that at 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.
3.1. Algorithm
The algorithm consists of the following steps:
Generate all subsets of the set that have the sum of
its elements equal to .
For each vertex , construct .
Construct a rooted tree with a root as a fixed element of
.
For a tree obtained
in Step (), find a successful
branch. Repeat Steps () and () for each element of until we find a successful branch
or run out of elements in .
To optimize the search space, we merge Step and Step into a new streamlined Step (), as below.
We explore the branches of as discussed in Step and Step with the following condition. Let the
tree be constructed to the level and , . Next, while adding children
at level to any of the nodes we will check the following two
conditions.
and
The part of the Step () ensures symmetry, which means
that is adjacent to if and only if is adjacent to . The part of Step () ensures that the neighborhood sum
of any vertex at any stage does not exceed the magic constant . Although this condition may not seem
critical at this point, it plays a crucial role in controlling the
growth of the tree (see Section 3.3). If
at least one of the conditions (1)
or (2) stated in Step are 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 order
and therefore the size of the tree , leading to an exponential
reduction in the search space.
Step () uses backtracking to
generate subsets of of the given sum .
The Step () of the algorithm
involves a backtracking strategy in the process of finding a successful
branch in the constructed tree . The algorithm systematically
explores the branches of each rooted tree, corresponding to a different
choice of elements from the set . If, during this exploration, it is
determined that a particular branch cannot lead to success, the
algorithm backtracks to the previous decision point and explores
alternative branches. This backtracking mechanism allows for an
exhaustive search of the solution space, ensuring that all possible
combinations of elements are considered. The backtracking in Step () is crucial to efficiently
navigate the complex solution space represented by the tree, avoiding
unnecessary computations and ultimately identifying successful branches
of .
We provide the pseudocode for the algorithm in the Appendix.
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 . This follows by observing that if
has a successful branch,
then the nodes on that branch constitute a graph .
Conversely, suppose that there is a graph . Consider a tree rooted at some element of . 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 . This
establishes the correctness of the algorithm.
3.3. Illustration for G(7,7)
Let us illustrate the steps of our algorithm with . By Theorem 2.7, we know that
there is only one graph up to isomorphism on
vertices admitting the magic constant . 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 pseudocode. 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 elements of the
set as children to the root
node as shown in Figure 4. The set of possible candidates for is
We have chosen ,
to maintain symmetry as stated in (1)
of Step , 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 the 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 must contain since , hence maintaining symmetry condition as given in (1) of Step .
Figure 4 A tree rooted at with a successful branch
In Figure 4, we have
illustrated a case of a successful branch (colored blue).
Now let us consider a case where we select the node instead of at the level (see the red colored branch in Figure
4). 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
. But then and the neighborhood sum of
the vertex is more than . This violates the condition of Step . Therefore, has no choices and we discard this
unsuccessful branch. This discarded branch is shown in red color in
Figure 4.
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 [14]. For any vertex , . Hence, we have an
upper bound .
By the definition of the distance magic graph, cannot be less than . Hence, we have , and the
lower bound is sharp. Therefore, to check whether a given positive
integer is a magic constant, we
need to run the algorithm for each pair , where .
Let be the largest 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]).
Figure 5 Non-isomorphic distance magic graphs of order up to
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 . The
algorithm generates multiple graphs that admit and as magic constants. As a
representative example, we list one of the such graphs in Figure 5. Due to the large
number of non-isomorphic distance magic graphs of order and (see Table 1), we will list all
non-isomorphic distance magic graphs of order up to (see Section 4).
Table 1 Number of non-isomorphic distance magic graphs of order up to
number of vertices:
number of non-isomorphic distance magic graphs
4. Distance magic graphs of order up to 10
In this section, we list all non-isomorphic distance magic graphs of
order up to in Figures 6–10.
Figure 6 Non-isomorphic distance magic graphs of order up to Figure 7 Non-isomorphic distance magic graphs of order Figure 8 Non-isomorphic distance magic graphs of order Figure 9 Non-isomorphic distance magic graphs of order Figure 10 Non-isomorphic distance magic graphs of order
5. Conclusions
There is no known polynomial-time algorithm to generate distance
magic graphs on a given number of vertices and a given magic constant.
Our algorithm presented in Section 3 is practically
implementable for considerably large order distance magic graphs. This
algorithm can be extended to generate -distance magic graphs introduced by
O’Neal et al. [10]. Let
be a graph and let denote the diameter of . Let and let be a multiset of positive real numbers
of size equal to the number of vertices in . A graph is said to be -distance magic if there is a bijection
such that
for all vertices , where and denotes the distance between and .
With the results known earlier and those verified in this paper, the
magic constants are now completely characterized, and we have the
following theorem.
Theorem 5.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 naturally leads to the
following questions.
Which magic constants are realized by connected distance magic
graphs?
For which pairs ,
there is unique distance magic graph on vertices with magic constant ?
We conclude by observing that it would be interesting to find a
non-algorithmic proof for the case .
Acknowledgements
The authors are grateful to Atharva Karandikar and Satyaprasad for
their invaluable assistance in implementing the algorithm.
Appendix
References:
S. Arumugam, D. Froncek, and N. Kamatchi. Distance magic graphs–A survey. Journal of the Indonesian Mathematical Society, (Special edition):11–26, 2011.
S. Arumugam, N. Kamatchi, and G. R. Vijayakumar. On the uniqueness of D-vertex magic constant. Discussiones Mathematicae. Graph Theory, 34(2):279–286, 2014. https://doi.org/10.7151/dmgt.1728.
B. 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.
J. A. Gallian. A dynamic survey of graph labeling (25th edition). Electronic Journal of Combinatorics, 5:Dynamic Survey 6, 43, 2022.
M. Jinnah. On Σ-labelled graphs. In B. Acharya and S. Hedge, editors, Technical Proceedings of Group Discussion on Graph Labeling Problems, pages 71–77. NITK Surathkal, 1999.
N. Kamatchi. Distance Magic and Distance Antimagic Labelings of Graphs. PhD Thesis, Kalasalingam Academy of Research and Education, Krishnankoil, Srivilliputhur, Tamil Nadu, June 2012.
P. Kováč, D. Fronček, and T. Kováčová. A note on 4-regular distance magic graphs. The Australasian Journal of Combinatorics, 54:127–132, 2012.
M. Miller, C. Rodger, and R. Simanjuntak. Distance magic labelings of graphs. The Australasian Journal of Combinatorics, 28:305–315, 2003.
A. O’Neal and P. J. Slater. An introduction to distance D magic graphs. Journal of the Indonesian Mathematical Society, (Special edition):91–107, 2011.
A. O’Neal and P. J. Slater. Uniqueness of vertex magic constants. SIAM Journal on Discrete Mathematics, 27(2):708–716, 2013. https://doi.org/10.1137/110834421.
R. Pawar and T. Singh. Distance magic labeling of generalized mycielskian graphs. arXiv:2306.07578, 2023.
S. Rao, T. Singh, and V. Parmeswaran. Some sigma labelled graphs I. In S. Arumugam, B. Acharya, and S. Rao, editors, Graphs, Combinatorics, Algorithms and Applications, pages 135–140. Narosa Publishing House, New Delhi, 2008.
V. Vilfred. Σ-Labelled Graphs and Circulant Graphs. PhD Thesis, University of Kerala, Trivandrum, Kerala, India, 1994.
D. B. West. Introduction to Graph Theory. Prentice Hall, 2nd edition, Sept. 2000.
F. Yasin and R. Simanjuntak. A heuristic for distance magic labeling. Procedia Computer Science, 74:100–104, 2015. https://doi.org/10.1016/j.procs.2015.12.083. The 2nd International Conference of Graph Theory and Information Security.