1. Introduction
In mathematics, the image is the set of the values of a mapping at all elements in the domain. In such an image, some structures of the domain are preserved. A mapping that preserves a structure, the one that we need to study, is usually known as a homomorphism. For graphs, a homomorphism is defined as follows.
Throughout this paper, all graphs are finite and simple, and we denote the vertex set and the edge set of a graph
G by
and
, respectively. Let
G and
H be two graphs. A mapping
f from
to
is known as a
from
G to
H if
for all
. When
,
f is an
on
G. The composition of homomorphisms is also known as a homomorphism. This leads to a preorder on graphs and a category [
1]. We use the symbol Hom(
) to denote the set of all homomorphisms from
G to
H and End(
G) to denote the set of all endomorphisms on
G.
In a simple graph, a
is a sequence of consecutive adjacent vertices. A
is a walk in which no vertex is repeated. We shall also use the word ‘path’ to denote a graph where the first and the last vertices have a degree one, and the other vertices have a degree two. Here,
stands for a path of order
n with
and
. Let us denote the path
with an edge-labeling
by
. Furthermore, refer to [
1,
2] for more basic definitions and results regarding graphs and algebraic graphs.
The formula for the number of endomomorphisms on
, |End(
)|, was introduced by Arworn [
3] in 2009. This number is calculated by the summation of the numbers of shortest paths from point
to any point
in a square lattice and an
r-ladder square lattice. Moreover, in the same year, Arworn and Wojtylak [
4] proposed a formula for the number of homomorphisms from
to
,
)|, in terms of
(
)|, where
(
)
for all
. In 2012, Lina and Zeng [
5] constructed another formula for
)|, which was obtained by proving the conjecture in [
6]. In 2014, Eggleton and Morayne [
7] also gave another formula for
)|. Moreover, they considered finite Laurent series to be generating functions that can move homomorphisms of a finite path into any path, finite or infinite.
In 2018, Knauer and Pipattanajinda [
8] studied a generalization of path endomorphisms, namely weak path endomorphisms. The number of weak path endomorphisms is calculated by the summation of the numbers of shortest paths from point
to any point
in a cubic lattice and in an
r-ladder cubic lattice. Recently, in 2022, Pomsri et al. [
9] proposed a formula for the number of weak homomorphisms from
to
in recursive form.
The Cartesian product of the graphs G and H is a graph with and . A rectangular grid graph or an grid graph is the Cartesian product of two path graphs on m and n vertices. There is one-to-one correspondence between the set of homomorphisms and the set of walks of n vertices in . Thus, the number of homomorphisms from a path to a grid graph gives the number of walks of n vertices in the rectangular grid graph.
In 2023, Keshavarz-Kohjerdi and Bagheri [
10] studied a rectangular grid graph in which some rectangles are removed from its corners, namely a truncated rectangular grid graph. They provided a linear-time algorithm for finding a Hamiltonian cycle problem in a truncated rectangular grid graph. These could be extended to the lower bound for the number of homomorphisms from a cycle to a rectangular grid graph.
Our purpose is to find a formula for the number of homomorphisms from a path to another path and to a rectangular grid graph .
2. The Number of Homomorphisms from Paths to Paths with f(0) = j
In this section, we provide the formula for finding the number of homomorphisms from paths to , which maps 0 to j. We denote the set of homomorphisms from to , which maps 0 to j, by .
By the symmetry of , we obtain the following lemma:
Lemma 1. Let j and n be integers such that . Here, we transform the cardinal number of
to count the shortest paths on square lattices.
Figure 1a–c show the possible homomorphisms from
to
, which map 0 to 0, 1, and 2, respectively. The numbers on the top are elements of the domain set
, and the tuples on the left are elements of the image set
. These become square lattices, as shown in
Figure 2a–c after rotating
counterclockwise.
Each homomorphism can be visualized using the square lattice, where movement from to the next point is depicted as follows:
To if .
To , if .
For example, if the images of successive vertices of
are
,
and 5, then the homomorphism can be visualized as shown in
Figure 3.
In general, can be obtained from the number of shortest paths from to any point on the square lattice that stays between the lines and , where touching is allowed.
Lemma 2 ([
5]).
The number of shortest paths from point to any point on the square lattice that stays between the lines and iswhere if or . Hence, we obtain the following theorem.
Theorem 1. Let be positive integers and j be a non-negative integer. Let and . Then, Example 1. Using Theorem 1, we haveandwhich is in line with counting directly from Figure 2. By counting the paths in Figure 2a, we have (see Figure 4). By counting the paths in Figure 2b, we have (see Figure 5). By counting the paths in Figure 2c, we have . (see Figure 6). For convenience, we compute
for
(
Table 1).
3. The Number of Homomorphisms from Paths to Rectangular Grid Graphs
In this section, we provide the formulas for finding the number of homomorphisms from paths to rectangular grid graphs . We denote the set of homomorphisms from to , which maps 0 to , by .
For
,
, let
From the symmetry of , we obtain the following lemma:
Lemma 3. Let i and n be integers such that , and let be a positive integer.
- (1)
,
for all and .
- (2)
.
- (3)
.
- (4)
.
- (5)
.
To prove the main theorem, we define a new operation for two paths with their edge labelings.
Definition 1. Let be paths with edge labelings ϕ and ψ. Define and entwined or as the set of all paths with edge labels from ϕ and ψ that preserve the sequential order of ϕ and ψ.
Example 2. Consider paths and with injective edge labelings ϕ and ψ, as shown below.
This leads to the following lemma:
Lemma 4. Let be paths with edge labelings. Then, Proof. It is easy to see that the number of ways to label is equal to the permutations of all edge labels with a fixed sequential order. □
Next, we observe a simple example to visualize homomorphisms from paths to rectangular grid graphs on a square lattice.
Example 3 (
).
All possible homomorphisms are shown in Figure 7. The numbers on the top are elements of the domain set , and the tuples on the left are elements of the image set . The tuples with the same second elements are represented by circles of the same color.The mappings with , , and are represented by the red lines on the top and the black lines (see Figure 8). We note that the normal black lines represent the increment of the first coordinate, the dashed black lines represent the decrement of the first coordinate, the normal red lines represent the increment of the second coordinate, and the red lines represent the decrement of the second coordinate. We now divide all mappings in into groups according to the number of change occurrences in the first coordinate h and rewrite each path as entwined black and red paths. For each , observe that out of the 3 edges of from , there are ways to place h edges from the black path and one way to place edges from the red path. Moreover, the black line is the square lattice representation of , while the red line is the square lattice representation of . Thus, there are possible paths in . Hence,
Example 4 (
).
All possible homomorphisms are shown in Figure 9. The numbers on the top are elements of the domain set , and the tuples on the left are elements of the image set . The tuples with the same second elements are represented by circles of the same color. Lemma 5. Let and k be positive integers and let be non-negative integers, such that and . It follows that Proof. Let . For each in the domain, either or . Assume changes in the first coordinate appear h times. Then, changes in the second coordinate appear times. The sequence of changes in the first coordinate form a homomorphism . Similarly, the sequence of changes in the second coordinate form a homomorphism . Thus, the corresponding path graph of f can be obtained from path graphs of and entwined. Hence, □
From Theorem 1, Lemma 3 and Lemma 5, we get the theorem below.
Theorem 2. Let and k be positive integers. The cardinalities of homomorphisms from paths to rectangular grid graphs are
where and where and .
For convenience, we compute
for
. The results are presented in
Table 2.
4. The Algorithm
In this section, we provide algorithms used to calculate ,
and with the aforementioned theorems.
Algorithms 1–3 are implementations of Theorem 1, Lemma 5 and Theorem 2, respectively.
Algorithm 1LocalPath2Path: Number of Homomorphisms from to with |
Input: |
- m: the size of the domain |
- n: the size of the range |
- Fixed value j where (with ) |
Output: number of homomorphisms from to with ifthen return 0 end if for to do for to do end for end for return
|
Algorithm 2LocalPath2Grid: Number of Homomorphisms from to with |
Input: |
- m: the size of the domain |
- : the dimensions of the grid representing the range |
- Fixed value where (with and ) |
Output: number of homomorphisms from to with for to do end for return homij
|
Algorithm 3Path2Grid: Number of Homomorphisms from to |
Input: |
- m: the size of the domain |
- : the dimensions of the grid representing the range |
Output: number of homomorphisms from to for to do for to do end for end for for to do end for for to do end for return
|
Lemma 6. Algorithm has time-complexity .
Proof. It is easy to see that the complexity of the algorithm depends on the first loop, which is also nested with rounds. Each round consists of an execution of LOCALPATH2GRID, which is essentially a loop with rounds. Each of these deeper rounds calls LOCALPATH2PATH twice.
To see the runtime for L
OCALP
ATH2P
ATH given parameters
m and
n, we first see the complexity of the outer loop:
Then, we consider the following scenarios:
: In this case ; hence, the inner loop has fixed rounds. Therefore, the complexity is at most .
: In this case, the complexity of the inner loop is
. Together, we have the overall complexity:
Therefore, the overall complexity of L
OCALP
ATH2P
ATH is
. Since each round of L
OCALP
ATH2G
RID calls L
OCALP
ATH2P
ATH twice, respectively with parameters
and
, we have its complexity as:
Together, the total complexity of PATH2GRID is . □
Author Contributions
Conceptualization, S.P.; methodology, S.P.; software, H.Y.; validation, H.Y.; investigation, P.R.; writing—original draft, P.R.; writing—review and editing, H.Y. and S.P.; visualization, H.Y. and P.R.; project administration, S.P.; funding acquisition, S.P. All authors have read and agreed to the published version of the manuscript.
Funding
This research was funded by Chiang Mai University.
Data Availability Statement
Data sharing not applicable.
Acknowledgments
We thank the reviewers for their insightful comments and suggestions that improved the quality of our manuscript. We wish to express our thanks to Pham Hoang Viet for several helpful comments concerning algorithm analyzing. This research was supported by Faculty of Science, Chiang Mai University, and Chiang Mai University, Thailand.
Conflicts of Interest
The authors declare no conflict of interest.
References
- Hell, P.; Nestril, J. Graphs and Homomorphisms; Oxford University Press: Oxford, UK, 2004. [Google Scholar]
- Knauer, U.; Knauer, K. Algebraic Graph Theory: Morphisms, Monoids and Matrices; Walter de Gruyter: Berlin, Germany, 2011. [Google Scholar]
- Arworn, S. An algorithm for the numbers of endomorphisms on paths. Discret. Math. 2009, 309, 94–103. [Google Scholar] [CrossRef] [Green Version]
- Arworn, S.; Wojtylak, P. An algorithm for the number of path homomorphisms. Discret. Math. 2009, 309, 5569–5573. [Google Scholar] [CrossRef] [Green Version]
- Lina, Z.; Zeng, J. On the number of congruence classes of paths. Discret. Math. 2012, 312, 1300–1307. [Google Scholar] [CrossRef] [Green Version]
- Michels, M.A.; Knauer, U.H. The congruence classes of paths and cycles. Discret. Math. 2009, 309, 5352–5359. [Google Scholar] [CrossRef] [Green Version]
- Eggleton, R.B.; Morayne, M. A Note on Counting Homomorphisms of Paths. Graphs Comb. 2014, 30, 159–170. [Google Scholar] [CrossRef] [Green Version]
- Knauer, U.; Pipattanajinda, N. A formula for the number of weak endomorphisms on paths. Algebra Discret. Math. 2018, 26, 270–279. [Google Scholar]
- Pomsri, T.; Wannasit, W.; Panma, S. Finding the Number of Weak Homomorphisms of Paths. J. Math. 2022, 2022, 2153927. [Google Scholar] [CrossRef]
- Keshavarz-Kohjerdi, F.; Bagheri, A. Finding Hamiltonian cycles of truncated rectangular grid graphs in linear time. Appl. Math. Comput. 2023, 436, 127513. [Google Scholar] [CrossRef]
| Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).