## 1 Introduction

Several graph polynomials have been introduced so far, as the chromatic polynomial [2], the Tutte polynomial, the Hosoya polynomial, and the *M*-polynomial. All these polynomials play important roles in graph theory, particularly due to their applications. The chromatic polynomial counts the number of distinct ways to color a graph with a number of given colors. The Tutte polynomial [5] became popular because of its universal property that any multiplicative graph invariant with a deletion-contraction reduction must be an evaluation of it. The Hosoya polynomial [4] counts the number of paths of different lengths in a molecular graph, and now plays a key role to find distance-based topological indices. The *M*-polynomial [3] plays a crucial role for degree-based topological indices parallel to the role the Hosoya polynomial plays for distance-based invariants.

In this paper we introduce the walk polynomial to find the number of walks of different lengths in a graph. We not only give a way of computing it but also give walk polynomial of the bipartite, star, wheel, and gear graphs.

## 2 Preliminaries

A *graph**G* is a pair (*V*, *E*), where *V* = {*v*_{1}, *v*_{2}, …, *v _{n}*} is the set of vertices and

*E*= {

*e*

_{1},

*e*

_{2}, …,

*v*} is the set of edges. An edge

_{m}*e*between two vertices

*u*and

*v*is denoted by

*e*= (

*u*,

*v*).

A *path* from a vertex *v* to a vertex *w* is a sequence of vertices and edges that starts from *v* and stops at *w*. The number of edges in a path is the *length* of that path. A graph is said to be *connected* if there is a path between any two of its vertices. The *distance**d*(*u*, *v*) between two vertices *u*, *v* of a connected graph *G* is the length of a shortest path between them. The diameter of *G*, denoted by *d*(*G*), is the longest distance in *G*.

A *walk* between two vertices *u* and *v* of *G* is finite alternating sequence *u* = *v*_{0}, *e*_{1}, *v*_{1}, *e*_{2}, *v*_{2}, *e*_{3}, *v*_{3}, …, *e _{k}*,

*v*=

_{k}*v*of vertices and edges of

*G*such that the edge

*e*joins the vertices

_{i}*v*

_{i–1}and

*v*

_{i}.

*[1] If A is the adjacency matrix of simple graph G*, *then the entry**a _{ij}* ∈

*A*.

^{k}is the number of different walks of length k between the vertices i and jIn the following we introduce the walk polynomial as a new graph invariant, a function which assigns a single value to all isomorphic graphs.

The *walk polynomial* in variable *x* of a simple connected graph *G* is defined as

where *A* is the adjacency matrix of *G*.

## 3 Main Results

In this section we give the walk polynomial of the complete bipartite, star, wheel, and gear graphs.

First of all we give the walk polynomial of the complete bipartite graph *K _{m,n}*.

*The walk polynomial of the complete bipartite graph**K _{m,n}*,

*m*≥ 2,

*n*≥ 1,

*is*𝓦 (

*K*) =

_{m,n}*mn*

*x*

^{1}+

Since the diameter of *K _{m,n}* is 2, we need only two matrices, the adjacency matrix

*A*and its square matrix

*A*

^{2}. In order to give the total number of walks of lengths 1 and 2, we first give the general forms of

*A*and

*A*

^{2}. The (

*m*+

*n*) × (

*m*+

*n*) adjacency matrix corresponding to

*K*is

_{m,n}where *O* and *J* are respectively matrices of zeros and ones. It is better to see the adjacency matrix of the bipartite graph *k*_{2,4}:

Since the upper triangular part of the adjacency matrix *A* is the matrix *J _{m,n}*, the sum of entries of this matrix is

*mn*. Thus the number of all walks of length 1 in

*J*is

_{m,n}*w*

_{1}=

*mn*. Similarly, the general form of

*A*

^{2}is

where *n*(*J _{m,m}*) represents the multiplication of

*J*with the number

*n*. The following is the second power of the adjacency matrix of the bipartite graph

*k*

_{2,4}.

The number *w*_{2} of walks of length 2 in *K _{m,n}* is

*mJ*–

_{n,n}*tr*

The following result gives the walk polynomial of the star graph *S _{n}*.

*Let S _{n} represent the star graph. Then*

Since the diameter of *S _{n}* is 2, we need only two matrices, the adjacency matrix

*A*and its square matrix

*A*

^{2}, each of order

*n*×

*n*:

where *O* and *J* are matrices of zeros and ones, respectively. You can see the adjacency matrix of *S _{7}*:

Since the upper triangular part of the adjacency matrix *A* is the matrix *J*_{1,n–1}, the sum of entries of this matrix is *n*–1. Thus the number of all walks of length 1 in *J*_{1,n–1} is *w*_{1} = *n*–1. Similarly, the general form of *A*^{2} is

where *n*(*J*_{1,1}) represents the multiplication of *J*_{1,1} with the number *n*–1. The following is the second power of the adjacency matrix of *S*_{7}.

Note that the walks of length 2 the contribution comes only from the matric *J*_{n–1,n–1}, and in this case the sum of all entries of this matrix is (*n*–1)^{2}. Now the number of walks of length 2 in *S _{n}* is

and the proof is finished.

In the following we are going to give walk polynomial of the wheel graph *W _{n}*.

*The walk polynomial of wheel graph is* 𝓦(*W _{n}*) = (2

*n*–2)

*x*

^{1}+ 1/2(

*n*

^{2}+ 3

*n*–4)

*x*

^{2}

*for n*≥ 3

*with*2

*n*–2

*edges and n vertices*.

Here, again, the diameter of the wheel graph is 2. So, again, we need just two matrices, the adjacency matrix *A* and its square *A*^{2}. The adjacency matrix corresponding to *W _{n}* is

*A*= (

*a*), where

_{ij}For better understanding, please the following adjacency matrix of *W _{7}*.

You can see that there are three types of entries where nonzero entries appear; the nonzero entries are actually 1s. The first type of entries appear at positions where either *i* = 1 or *j* = 1, and their count is 2(*n*–1); The second type of entries appear at positions where either *i* = *j* + 1 or *j* = 1 + 1, and their count is 2((*n*–1)–1); The third type of entries appear at positions where either *i* = 2, *j* = *n* or *i* = *n*, *j* = 2, and their count is 2. You may observe that all the entries of main diagonal are 0. So, the number of all distinct walks of length 1 in *W _{n}* is

*A*

^{2}= (

*b*) are

_{ij}The following is *A*^{2} of *W*_{7}.

Now we give the sum of all the entries: and the first type of entries are all 1s and appear at the positions where *j* = i + 1, and their count is (*n*–2). The second type of entries are all 1s and appear at the positions where *i* = 2, *j* = *n*, and their count is 1. The third type of entries are all 2s and appear at the positions where *j* = *i* + 2, *i* = 2 and their count is (*n*–3); The fourth type of entries are all 2s and appear at the positions where*i* = 2, *j* = *n*–1, and their count is 1; the fifth type of entries are all 2s and appear at the positions where *i* = 3, *j* = *n*–1, and their count is 1; the sixth type of entry is are all 2s and appear at the positions where *i* = 1, *j* = 2, …, *n*, and their count is (*n*–1); the seventh type of entries are all 1s and appear at the positions where *j* = *i* + 3, …, *i* + (*n*–4), 2 ≤ *i* ≤ *n*–3, *i* + *n*–4 ≤ *n*, and their count is
*W _{n}* is

In the following we are going to give walk polynomial of the gear graph *G _{n}*.

*The walk polynomial of the gear graph**G _{n}*,

*n*≥ 6,

*is*

Since the diameter of the gear graph is 4, we need four matrices, *A*, *A*^{2}, *A*^{3}, and *A*^{4}.

**Walks of lengths 1**: Since only the upper-triangular entries contribute towards the walk polynomial, we give only the nonzero upper-triangular entries of the (2*n* + 1) × (2*n* + 1) adjacency matrix *A* = (*a _{ij}*) of

*G*:

_{n}Let us have a look at the adjacency matrix of *G*_{7}:

You can see that there are three types of entries where nonzero entries appear; the nonzero entries are actually 1s. The first type of entries appear at positions where *i* = 1, …, 2*n*–1 and *j* = *i* + 1, and so their count is 2*n*–1; the second type of entries appear at positions where *i* = 1 and *j* = 2*n*, and so their count is 1; the third type of entries appear at positions where *i* is odd and is less than 2*n* + 1 and *j* = 2*n* + 1, and so their count is *n*. So, the number of all distinct walks of length 1 in *G _{n}* is

*w*

_{1}= ((2

*n*–1) + 1 +

*n*) = (3

*n*).

**Walks of lengths 2**: Now we find walks of lengths 2. The upper triangular entries of *A*^{2} = (*b _{ij}*) are

For better understanding you may have a look at the walks of lengths 2 in the matrix *A*^{2} of *G*_{7}.

Now we give the sum of all these entries. The first type of entries are all 2s and appear at positions where *i* is odd and 1 ≤ i ≤ (2*n*–3), *j* = *i* + 2, and their count is (*n*–1). the second type of entries are all 1s and appear at positions where *i* is even and 2 ≤ *i* ≤ (2*n*–2) and *j* = *i* + 2, and their count is (*n*–1); the third type of entries are all 2s and appear at positions where *i* is even and 2 ≤ *i* ≤ (2*n*) and *j* = 2*n* + 1, and their count is *n*; the fourth type of entries are all 1s and appear at positions where *i* is odd and 1 ≤ *i* ≤ (2*n*–5) and *j* = *i* + 4, and their count is *n*–2; the fifth type of entry is are all 1s and appear at positions where *i* is odd and 1 ≤ *i* ≤ (2*n*–7) and *j* = *i* + 6, and their count is (*n*–3); the sixth type of entries are all 1s and appear at positions where *i* is odd and 1 ≤ *i* ≤ 3 and *j* = *i* + 8, and their count is (*n*–4); the seventh type of entries are all 2s and appear at positions where *i* = 1, *j* = 2*n*–1, and their count is 1. The eighth type of entries are all 1s and appear at positions where *i* = 2, *j* = 2*n*, and their count is 1. So, the number of all distinct walks of length 2 is

**Walks of lengths 3**: In order to find walks of length 3, we need upper triangular entries of the matrix *A*^{3}:

The following is the matrix *A*^{3} of *G*_{7}.

Now we give the sum of all entries of above diagonals. The first type of entries are 2s. These entries appear in *n*–4 secondary diagonals, and the entries appear as follows:

Since the number of 2s appearing at these positions is *n*(*n*–4), their sum is 2*n*(*n*–4).

The second type of entries are 5s. These numbers appear on secondary diagonal with 1 ≤ *i* ≤ 2*n*–1 and *j* = *i* + 1, and their count is 2*n*–1. Moreover, one 5 appears at the position where *i* = 1, *j* = 2*n*. Since the total number of 5s is 2*n*, their sum is 10*n*.

The third type of entries are 3s. These entries appear only in 2 secondary diagonals, and their positions are:

Since the total number of 3s is 2*n*, their sum is 6*n*.

The fourth type of entries are *n* + 4*s* and appear at positions where *i* is odd and 1 ≤ *i* < 2*n* + 1 and *j* = 2*n* + 1. Since their count is *n*, the sum of these numbers is *n*(*n* + 4).

Finally, the number of all distinct walks of length 3 in *W _{n}* is 2

*n*(

*n*–4) + 10

*n*+ 6

*n*+

*n*(

*n*+ 4) = 3

*n*(

*n*+ 4).

**Walks of lengths 4**: Now we go for distinct walks of length 4 by giving upper triangular entries of the matrix *A*^{4} = (*d _{ij}*). You may observe that these entries will form secondary diagonals, which are divided into three types:

Type I.

Type II. The last two nonzero secondary diagonals are:

Type III. There are *n*–5 secondary diagonals such that the first entry of each of these diagonals is *n* + 8. In the following *m* denotes the number of such diagonals, i.e., 1 ≤ *m* ≤ *n*–5.

The entries which are not covered yet are the entries of the last column of *A*^{4}:

The following is the matrix *A*^{4} of *G*_{7}.

Now we give the sum of all these upper-triangular entries. There are four diagonals that appear once in the matrix. The entries of the first such diagonal are *n* + 12 and 8 and each of these appear *n*–1 times, and so there sum is (*n*–1)(*n* + 12) + 8(*n*–1). The entries of the second such diagonal are *n* + 9 and 5 and each of these appear *n*–2 times, and so there sum is (*n*–2)(*n* + 9) + 5(*n*–2). The entries of the third such diagonal are *n* + 9 and 5 and each of these appear 2 times, and so there sum is 2*n* + 28. The entries of the fourth such diagonal are *n* + 12 and 8 and each of these appears 1 time, and so there sum is *n* + 20.

Now we find the sum of those *n*–5 diagonals whose entries are same but appear with different number of times. Each such diagonal has two types of entries, *n* + 8 and 4. The largest of these diagonals contains *n*–3 entries of value *n* + 8, the next contains *n*–4 entries of value *n* + 8, and so on the last such diagonal contains 3 entries. Thus the sum of all these entries is

Similarly, since 4 appears the same number of times the *n* + 8 appears, their sum is *Sum*_{2} = 2*n*(*n*–5).

Since the entries 2*n* + 8 in the last column appear *n* times, their sum is *n*(2*n* + 8).

Finally, the sum of all upper-triangular entries of *A*^{4} is

*The walk polynomial of the Jahangir graph**J*_{2,m}, *m* ≥ 6, *is*

Just substitute *m* for *n* in the walk polynomial of the gear graph *G _{n}*.

^{}

Communicated by Juan L.G. Guirao

^{}

**Funding**: Not applicable.

^{}

**Authors’ Contribution**: All authors contribute equally in this paper.

^{}

**Competing Interests**: The author(s) do not have any competing interests in the manuscript.

Not applicable.

## References

- [2]↑
G. D. Birkhoff, A Determinant Formula for the Number of Ways Coloring a Map, Annal. Math., 14(2) (1912): 42-46.

- [3]↑
E. Deutsch and S. Kavžar, M-polynomial and degree-based topological indices, Iran. J. Math. Chem., 6 (2015), 93-102.

- [5]↑
W. T. Tutte, A Contribution to the Theory of Chromatic Polynomials, Canadian J. Math., 6 (1954), 80-91.