1 Introduction

Let \( {\mathbb {F}}_{q} \) be the finite field of order q. A linear [nkd] code C is a subspace of \({\mathbb {F}}^{n}_{q} \) of dimension k and minimum distance d. If C is linear, a subcode of C is a linear subspace of C. The dual code of C, represented as \( [n,n-k] \) code \( C^{\bot } \), is the orthogonal complement of the subspace C of \( {\mathbb {F}}^{n}_{q} \) with respect to the usual inner product of \( {\mathbb {F}}^{n}_{q} \). For \( 1 \le r \le k \), the r th generalized Hamming weight of C, denoted by \( d_{r}(C) \), is defined as follows.

$$\begin{aligned} d_{r}(C)=\min \{ \vert \chi (D)\vert : D {\text { is a subcode of }}\; C \text {of dimension } r \}, \end{aligned}$$

where \( \chi (D)\) is the support of subcode D such that for \( 1 \le i \le n \)

$$\begin{aligned} \chi (D)=\mathrm{{supp}}(D)=\{ i: \text {there is a codeword } ( w_{1},w_{2},\ldots ,w_{n} )\in D \text { with}\; w_{i}\ne \mathrm {0} \}. \end{aligned}$$

The set \( \{d_{r}(C): 1\le r \le k\} \) is called the weight hierarchy of the code C.

The concept of generalized Hamming weights was first introduced by Helleseth, Kløve and Mykkeltveit in [12]. In 1991, V. K. Wei studied them in connection with cryptography. Since his paper [27], much attention has been given to generalized Hamming weights of linear codes. As he showed the performance of a linear code in some cryptographical applications can be characterized by them. From then on, many authors have determined or estimated generalized Hamming weights of different codes and [1,2,3, 7, 8, 11, 14, 15, 20,21,22,23,24,25,26, 28,29,31] are some of these papers.

For a linear [nk] code, a generator matrix is an \( k \times n \) matrix G whose rows form a basis for C and a parity check matrix H is an \( (n-k) \times n \) generator matrix for the dual code \( C^{\bot } \).

The following results are quoted from Wei’s paper.

Theorem 1

[27, Theorem 1] For every linear [nk] code C with \( k>\mathrm {0} \),

$$\begin{aligned} 1 \le d_{1}(C)<d_{2}(C)<\cdots <d_{k}(C)\le n . \end{aligned}$$

Theorem 2

[27, Theorem 2] Let C be a linear [nk] code. Let H be a parity check matrix of C and \( H_{i} \) for \( 1 \le i \le n \) be its column vectors. Then,

$$\begin{aligned} d_{r}(C) = min \{\vert I \vert : \vert I \vert - rank(\langle H_{i}: i\in I \rangle )\ge r\}. \end{aligned}$$

The next result, known as Duality, shows a relationship between the rth generalized Hamming weight of code C and its dual code.

Theorem 3

[27, Theorem 3] Let C be a linear [nk] code and let \( C^{\bot } \) be its dual code. Then,

$$\begin{aligned} \{d_{r}(C): 1 \le r \le k \} = \{1,2,\dots ,n\} \setminus \{n+1-d_{r}(C^{\bot }): 1 \le r \le n-k \}. \end{aligned}$$

A linear [nkd] code C is called r-MDS if \( d_{r}(C)=n-k+r \). If a linear code C has subcodes \( D_{r} \) for \( 1 \le r \le k \) such that \( D_{\mathrm {0}}=\mathrm {0} \), \(rank(D_{r})=r \), \( \vert \chi (D_{r})\vert =d_{r} \) and \( D_{r-1} \) is a subcode of \( D_{r}\), then code C satisfies the chain condition [28].

In the next lemma, we present other bounds on the generalized Hamming weights of linear codes.

Lemma 1

[25, Theorem 3.1, Corollary 3.3] Let C be a linear [nk] code over \( F_{q} \). Then for \( 1 \le r \le k \),

  1. (1)

    Griesmer-type bound:

    $$\begin{aligned} d_{r} (C) \ge \sum \limits _{{i = 0}}^{{r - 1}} {\left\lceil {\frac{{d_{1} }}{{q^{i} }}} \right\rceil } ; \end{aligned}$$
  2. (2)

    Plotkin-type bound:

    $$\begin{aligned} d_{r} (C) \le \left\lfloor {\frac{{n(q^{r} - 1)q^{{k - r}} }}{{q^{k} - 1}}} \right\rfloor . \end{aligned}$$

A graph G is made up of a set of vertices V(G) and a set of unordered pairs of vertices called edges denoted by E(G) . The number of vertices and edges in a graph G is called the order and size of G, respectively. Two distinct vertices are neighbors if they are joined by an edge. The degree of a vertex v in G, denoted by deg(v) , is the number of its neighbors. The minimum degree among all vertices of G is the minimum degree of G and denoted by \(\delta (G)\). For \( k \in {\mathbb {N}} \), a graph G is called k-regular when all vertices of G have the same degree k. A perfect matching is a set of disjoint edges with the property that each vertex of graph is incident to only and only one of these edges. A path \( P_{n} \) is the graph of order n and size \( n-1 \) with vertex set \( V(P_{n})=\{v_{1},v_{2},...,v_{n}\} \) and edge set \( E(P_{n})=\{v_{1}v_{2},v_{2}v_{3},...,v_{n-1}v_{n}\}\). Note that vertices of a path are distinct. A cycle \( C_{n} \) is the graph of order n and size n with vertex set similar to \(P_{n} \) and edge set \( E(C_{n})= E(P_{n})\cup \{v_{n}v_{1}\}\). The complete graph on n vertices \( K_{n} \) is the graph where every two distinct vertices are connected by an edge. The Cartesian product of two graphs G and H, denoted by \( G\square H \), is the graph with vertex set \( V(G) \times V(H) \) and two distinct vertices (uv) and \( (u', v') \) of graph are adjacent if either \( u = u'\) and \(vv' \in E(H) \) or \(v=v'\) and \(uu'\in E(G) \). The hypercube \( Q_{n} \) is the graph whose vertices are n-tuples with entries in \( \{0,1\} \) and two vertices are connected if and only if their corresponding n-tuples differ in exactly one position. Rook’s graph is the Cartesian product of two complete graphs. A grid is the Cartesian product of two paths. The length of a shortest cycle in graph G is the girth of G and is denoted by g(G) . A subset \( S \subseteq E(G) \) is called an edge cut of a connected graph G such that \( G \backslash S \) is disconnected. The minimum cardinality of an edge cut is called edge connectivity \( \lambda (G)\). A graph G is called super-\( \lambda \) if \( \lambda (G) \) is equal to the minimum degree of G and in addition, only the removal of the sets of edges incident to a vertex of minimum degree disconnects G. The r th edge connectivity of G, denoted by \(\lambda _{r}(G)\), is the minimum number of edges whose removal results in a graph with \( r + 1 \) connected components. If \( r=1 \), then \( \lambda _{1}(G)=\lambda (G) \).

An incidence matrix of G is a matrix \( A=[a_{v,e}] \), where each row corresponds to a vertex v and each column corresponds to an edge e and \(a_{v,e}=1 \) whenever v and e are incident and otherwise \(a_{v,e}=0 \).

For a graph G, C(G) denotes the binary linear code with parity check matrix \( A=A(G) \), the incidence matrix of G.

For additional information, we refer the reader to [5] for graph theory, [4] for algebraic graph theory and [13] for coding theory.

There are many papers studying the linear codes generated by the incidence matrices of graphs (see, e.g. [6, 9, 10, 16, 17]). We recall one of the results given in [6]. Note that we consider the incidence matrix as the parity check matrix of a linear code. Hence, all theorems quoted from [6] are adapted versions of them.

Theorem 4

[6, Theorem 6] Let \( G=(V,E) \) be a connected graph and let A(G) be the incidence matrix of G. Suppose that C(G) is the binary linear code with parity check matrix \( A=A(G) \). Then, C(G) is a \([\vert E \vert , \vert E \vert -\vert V\vert +1, g(G)]\) binary code.

Remark 1

[19, Remark 1] If graph G in Theorem 4 is disconnected, then \( k=\vert E \vert -\vert V\vert +c \), where k is the dimension of C(G) and c is the number of connected components of G.

The following result found in [6] gives the parameters of the dual code of C(G) .

Theorem 5

[6, Theorem 1] Let \( G=(V,E) \) be a connected graph and let A(G) be the incidence matrix of G. Suppose that C(G) is the binary linear code with parity check matrix \( A=A(G) \). If \( C^{\bot }(G) \) is the dual code of C(G) . Then,

  1. (1)

    \( C^{\bot }(G)=[\vert E \vert , \vert V\vert -1, \lambda (G)]; \)

  2. (2)

    If G is super-\( \lambda \), then \( C^{\bot }(G)=[\vert E \vert , \vert V\vert -1, \delta (G)] \).

Martínez-Bernal et al. [21] determined the rth generalized Hamming weights of linear codes generated by the incidence matrices of signed graphs and their dual codes. In the following result given in [20], they obtained the generalized Hamming weights of \( C^{\bot }_{p}(G) \) when G is connected. Note that it is modified based on our assumptions, as we consider the incidence matrix as the parity check matrix of a linear code.

Theorem 6

[20, Corollary 2.13] Let G be a connected graph with n vertices, m edges, rth edge connectivity \( \lambda _{r}(G) \) and let A be the incidence matrix of G over a field of characteristic p. Suppose that \( C_{p}(G) \) is the linear code with parity check matrix A. Let \( C^{\bot }_{p}(G) \) be the dual code of \( C_{p}(G) \). If \( p = 2 \) or G is bipartite, then

$$\begin{aligned} d_{r}(C^{\bot }_{p}(G))= \lambda _{r}(G). \end{aligned}$$

In [19], we worked on the binary linear codes determined in [6]. We obtained the rth generalized Hamming weights of binary linear codes derived from complete graphs, complete bipartite graphs, triangular graphs and Kneser graphs K(n, 2) and their dual codes. In this paper, we deal with binary linear codes arising from Cartesian product of some graphs.

The remaining of this paper is organized as follows. In Sect. 2, we quote the results from [19] which have the main roles in the next sections. In Sect. 3, we obtain the generalized Hamming weights of binary linear codes derived from hypercubes and their duals. Then, we determine the rth generalized Hamming weights of binary linear codes arising from rook’s graphs, grid graphs, \( C_{m}\square P_{n} \) and \(C_{m}\square C_{n}\) and their duals in Sects. 47, respectively. We also show when these codes are r-MDS, whether they satisfy the chain condition or not and when the rth generalized Hamming weight meets the Griesmer-type bound and the Plotkin-type bound.

2 Preliminaries

In this part, we present some of the results that will be used in the next sections.

For a nonempty subset \( S \subseteq V(G) \), the subgraph of G induced by S is the graph G[S] whose vertex set is S and whose edge set is \( \{v_{1}v_{2}\in E(G): v_{1},v_{2}\in S\} \). A subgraph H of a graph G is an induced subgraph of G if there exists a nonempty subset \( S \subseteq V(G) \) such that \( H=G[S] \). For a nonempty subset \( S' \subseteq E(G) \), the subgraph of G induced by \( S' \), denoted by \( G[S'] \), is the graph which has \( S' \) as edge set and its vertex set contains the vertices of G which are incident to an edge in \( S' \). A subgraph H of a graph G is a spanning subgraph of G if \( V(H)=V(G) \) and \( E(H)\subseteq E(G) \).

The next Theorem is the key in the proofs of all the given results in this paper.

Theorem 7

[19, Theorem 6] Let G be a connected graph with incidence matrix A and \( C=C(G) \). Let D be a subcode of C with dimension r such that \( \vert \chi (D) \vert =d_{r}(C)\). Then, there exists a spanning subgraph K of G such that \( D=C(K) \), hence \( d_{r}(C)=\vert E(K)\vert \).

Remark 2

[19, Remark 2] Based on Theorem 7, we must find a subgraph H of minimum order such that \( D=C(H) \) to obtain \( d_{r}(C) \) for a connected graph G. Therefore, \(r=\vert E(H)\vert -\vert V(H)\vert +c'\), where \( c' \) is the number of connected components of H. Hence,

\( \vert \chi (D)\vert =d_{r}(C)=\vert E(H)\vert \).

3 GHWs of codes arising from hypercubes

In this section, we determine generalized Hamming weights of the binary linear code C with parity check matrix A, the incidence matrix of a hypercube. It is not difficult to see that \( Q_{n}=K_{2}\square Q_{n-1} \).

Theorem 8

Let G be a hypercube \( Q_{n} \). Then for any \(1 \le r\le n2^{n-1}-2^{n}+1\),

$$\begin{aligned} d_{r}(C)=r+\sum _{i=0}^{t}2^{s_{i}}-1, \end{aligned}$$

where \( s_{0} \) is the maximum integer satisfying \(r\ge s_{0}2^{s_{0}-1}-2^{s_{0}}+1 \) and \( s_{i} \) for \( 1 \le i \le t \) is the maximum integer such that \(s_{o}>s_{1}>s_{2}>\dots >s_{t} \) and the inequality

$$\begin{aligned} r-\sum _{i=0}^{a-1}\left[ s_{i}2^{s_{i}-1}+(i-1)2^{s_{i}}+1\right] \ge s_{a}2^{s_{a}-1}+(a-1)2^{s_{a}} \end{aligned}$$

holds, where \( 1 \le a \le t \) and put \(s_{t}=0 \) whenever \( s_{t}<0 \).

Proof

By Theorem 4, \(C=C(G) \) is a \( [n2^{n-1},n2^{n-1}-2^{n}+1,4] \) binary code, since \( g( Q_{n})=4 \). By Remark 2, let D be a subcode of C(G) such that \( \vert \chi (D)\vert =d_{r}(C) \). Hence, there exists a subgraph H of G such that \( dim(C(H))=r =m'-n'+c'\), where \( m' \) and \( n' \) are the size and order of H, respectively. Therefore, \( d_{r}(C)=m' \). Note that for any \( 0 \le s_{0}\le n \), \( Q_{s_{0}} \) is a subgraph of \( Q_{n} \) and \( dim(C(Q_{s_{0}}))=\vert E(Q_{s_{0}})\vert -\vert V(Q_{s_{0}})\vert +1=s_{0}2^{s_{0}-1}-2^{s_{0}}+1\), as \( Q_{s_{0}} \) is connected. So we choose the maximum \( s_{0} \) such that \( r=m'-n'+1\ge s_{0}2^{s_{0}-1}-2^{s_{0}}+1 \). We conclude that H contains \( Q_{s_{0}} \), which is a subgraph of \( Q_{s_{0}+1} \). It is obvious that \( Q_{s_{0}+1} \) can be decomposed into two copies of \( Q_{s_{0}} \) connected by a perfect matching. As in graph \( Q_{s_{0}+1} \), each vertex of the other copy of \( Q_{s_{o}} \) also has one neighbor in the first copy; therefore, it is enough to find the maximum integer \( s_{1}<s_{o}\) satisfying

$$\begin{aligned} r-dim(C(Q_{s_{0}})) \ge s_{1}2^{s_{1}-1}+2^{s_{1}}-2^{s_{1}}= s_{1}2^{s_{1}-1}. \end{aligned}$$

Hence, H has at least \( n_{Q_{s_{0}}}+n_{Q_{s_{1}}} \) vertices and \(m_{Q_{s_{0}}}+m_{Q_{s_{1}}}+2^{s_{1}} \) edges. If we continue this process, since each vertex of \( Q_{s_{i}} \) has a neighbor in \(Q_{s_{0}}, Q_{s_{1}}, \dots , Q_{s_{i-1}}\), so each time \(i2^{s_{i}}\) edges are added to the graph other than \( m_{Q_{s_{i}}} \). Hence in order to find the remaining vertices of subgraph H in the second copy of \( Q_{s_{0}} \), we should find the maximum integer \( s_{i} \) satisfying

$$\begin{aligned}&r-\sum _{i=0}^{a-1}\left[ s_{i}2^{s_{i}-1}+i2^{s_{i}}-2^{s_{i}}+c'\right] = r-\sum _{i=0}^{a-1}\left[ s_{i}2^{s_{i}-1}+(i-1)2^{s_{i}}+1\right] \\&\quad \ge s_{a}2^{s_{a}-1}+(a-1)2^{s_{a}} , \end{aligned}$$

where \( 1 \le a \le t \). It is clear that H is connected, \( c'=1 \) and also \(s_{o}>s_{1}>s_{2}>\dots >s_{t} \). In this process, when \( s_{t}<0 \), it shows that the remaining edges belong to one vertex, so we put \(s_{t}=0 \), it means \( n= \sum _{i=0}^{t-1}2^{s_{i}}+1\). Therefore,

$$\begin{aligned} d_{r}(C)=\vert E(H) \vert =r+\sum _{i=0}^{t}2^{s_{i}}-1. \end{aligned}$$

\(\square \)

Corollary 1

If \( G=Q_{n} \), then

  1. 1.

    The code C(G) is r-MDS for \(n2^{n-1}-2^{n}-n+3 \le r\le n2^{n-1}-2^{n}+1 \).

  2. 2.

    The code C(G) satisfies the chain condition.

  3. 3.

    \( d_{r}(C) \) meets the Griesmer-type bound for \( r=1 \).

  4. 4.

    \( d_{r}(C) \) meets the Plotkin-type bound for \(r=k-1 \) when \( 3 \le n \le 4 \) and for \( r=k \) for all n.

Proof

Let \( G=Q_{n} \), then

(1) : By considering the definition of r-MDS codes and the result of Theorem 8, it can be seen that code C(G) is r-MDS when the last vertex in the process of obtaining \( d_{r}(C) \) is added to the graph. As \( Q_{n} \) is n-regular, \( d_{r}(C)=\vert E(G) \vert -dim(C(G))+r \) for

$$\begin{aligned} n2^{n-1}-2^{n}-n+3 \le r\le n2^{n-1}-2^{n}+1 . \end{aligned}$$

(2) : This is straightforward from the proof of Theorem 8.

(3), (4) : These follow from Theorem 8 and Lemma 1.

\(\square \)

In the next result, Li et al. obtained the upper bound for the size of the subgraph induced by v vertices of a hypercube.

Theorem 9

[18, Theorem 1] Let X be a vertex set of \( Q_{n} \) such that \( \vert X \vert =v \). Then, a subgraph induced by v vertices has at most \( \frac{1}{2} ex_{v}\) edges, where

$$\begin{aligned} ex_{v}=\sum _{i=0}^{s}t_{i}2^{t_{i}}+\sum _{i=0}^{s}i2^{t_{i}+1}, \end{aligned}$$

such that \( v=\sum _{i=0}^{s}2^{t_{i}} \), \( t_{0}=[log_{2}v] \) and \( t_{i}=[log_{2}(v-\sum _{r=0}^{i-1}2^{t_{r}})] \) for \( i\ge 1. \)

Theorem 10

If \( G=Q_{n} \), then for any \(1 \le r\le 2^{n}-1\),

$$\begin{aligned} d_{r}(C^{\bot }(G))=n2^{n-1}-\frac{1}{2}ex_{2^{n}-r}. \end{aligned}$$

Proof

It follows from Theorem 5 that \(C^{\bot }=C^{\bot }(G)\) is a \([n2^{n-1},2^{n}-1,n] \) binary code, as \( \lambda (G)= \delta (G)=3\) and graph G is super-\( \lambda \). It follows from Theorem 6 that we should find the rth edge connectivity of graph to obtain \(d_{r}(C^{\bot })\). Graph G is regular, so it becomes a graph with \( r+1 \) components by removing the edges incident to any r vertices. Clearly \(d_{1}(C^{\bot })=\lambda (G)=3 \). Hence, it is enough to subtract the maximum number of edges of an induced subgraph obtained by the remaining vertices of \( Q_{n} \) using Theorem 9. Therefore,

$$\begin{aligned} d_{r}(C^{\bot })=\lambda _{r}(G)=n2^{n-1}-\frac{1}{2}ex_{2^{n}-r}. \end{aligned}$$

\(\square \)

Example 1

Let \( G=Q_{3} \). Then, the weight hierarchies of C(G) for \( 1\le r \le 5 \) and of \( C^{\bot }(G) \) for \( 1 \le r \le 7 \) are shown in Table 1. Moreover, the code C(G) is r-MDS for \( 4 \le r \le 5 \) and \( d_{r}(C) \) meets the Griesmer-type bound and the Plotkin-type bound for \( r=1 \) and for \( 6 \le r \le 7\), respectively.

Table 1 The generalized Hamming weights of \( C(Q_{3}) \) and \( C^{\bot }(Q_{3}) \)

4 GHWs of codes arising from rook’s graphs

Now we consider the binary linear codes which have the incidence matrices of rook’s graphs as parity check matrices and obtain the generalized Hamming weights of them.

Theorem 11

Let G be a rook’s graph \(K_{m}\square K_{n}\) such that \( m\le n \) and \( n\ge 3 \). Then for any \(1 \le r\le \frac{mn(m+n)}{2}-2mn+1\),

$$\begin{aligned} d_{r}(C)=r+an+b-1, \end{aligned}$$
(1)

where a is the maximum integer such that the inequality

$$\begin{aligned} a{n \atopwithdelims ()2}+n{a \atopwithdelims ()2}-an+1\le r \end{aligned}$$
(2)

holds and b is the minimum integer satisfying

$$\begin{aligned} a{n \atopwithdelims ()2}+n{a \atopwithdelims ()2}+{b\atopwithdelims ()2}-an+ab-b+1 \ge r. \end{aligned}$$

Proof

By Theorem 4, \( C=C(G) \) is a \( [\frac{mn(m+n)}{2}-mn, \frac{mn(m+n)}{2}-2mn+1,3] \) binary code, as \( g(G)=3 \). Let \( V(K_{m})=\{u_{1},u_{2},\dots ,u_{m}\} \) and \( V(K_{n})=\{v_{1},v_{2},\dots ,v_{n}\}\). First we consider a partition \( \{C_{1}, C_{2}, \ldots , C_{m}\} \) of vertices of G such that for \( 1\le i \le m \), \( C_{i}=\{(u_{i},v_{1}),(u_{i},v_{2}),\dots ,(u_{i},v_{n})\} \). It is clear that \(\vert C_{i} \vert =n\). As the vertices of each set form a clique, there are \( {n \atopwithdelims ()2} \) edges between them. On the other hand, each vertex also has one neighbor in every previous set. By Remark 2, let D be a subcode of C(G) such that \( \vert \chi (D)\vert =d_{r}(C) \). Hence, there exists a subgraph H of G such that \( dim(C(H))=r =m'-n'+c'\), where \( m' \) and \( n' \) are the size and order of H, respectively. Therefore, \( d_{r}(C)=m' \). We construct the subgraph H by adding the vertices of the set \( C_{1} \) and then the sets \( C_{i+1} \) for \( 1 \le i \le m-1 \) according to the order in which they are placed in these sets. Therefore, H is connected and \( c'=1 \). If \( H' \) is a subgraph of G such that \( V(H')=\cup _{i=1}^{a}C_{i}\) for \( 1 \le a \le m \), then \( H'\) has exactly \( n_{a}=an \) vertices and \( m_{a} \) edges, where \(m_{a}=a{n \atopwithdelims ()2}+n(1+2+...+(a-1))=a{n \atopwithdelims ()2}+n{a \atopwithdelims ()2 } \). Therefore, \( dim(C(H'))=m_{a}-n_{a}+1 \), as \( H' \) is connected. To get \( d_{r}(C) \), first we should find the maximum integer a such that the inequality \(m_{a}-n_{a}+1 \le r \) holds. Therefore, H has at least \(n_{a}\) vertices and \(m_{a} \) edges. Now we should find the number of required vertices from the \( (a+1) \)th set, so it is enough to obtain the minimum integer b satisfying

$$\begin{aligned} m_{a}+{b\atopwithdelims ()2}+ab-(n_{a}+b)+1=a{n \atopwithdelims ()2}+n{a \atopwithdelims ()2}+{b\atopwithdelims ()2}-an+ab-b+1 \ge r. \end{aligned}$$

Hence, we have

$$\begin{aligned} d_{r}(C)=\vert E(H)\vert =r+an+b-1. \end{aligned}$$

\(\square \)

Corollary 2

If \(G=K_{m}\square K_{n}\) such that \( m \le n \) and \( n\ge 3 \), then

  1. (1)

    The code C(G) is r-MDS for

    $$\begin{aligned} \frac{mn(m+n)}{2}-2mn-m-n+5\le r \le \frac{mn(m+n)}{2}-2mn+1 . \end{aligned}$$
  2. (2)

    The code C(G) satisfies the chain condition.

  3. (3)

    \( d_{r}(C) \) meets the Griesmer-type bound for \( r=1 \) when \( n=3 \) and for \( 1 \le r \le 3 \), otherwise.

  4. (4)

    \( d_{r}(C) \) meets the Plotkin-type bound for \(r=k-1 \) when \(G=K_{1}\square K_{n}= K_{n} \) for \( 4 \le n\le 10 \) or \(G=K_{2}\square K_{n} \) for \( n\le 7 \) or \(G=K_{3}\square K_{n} \) for \( n\le 5 \) and also for \( G=K_{4}\square K_{4} \) and for \( r=k \) for all \( n \ge 3 \).

Proof

Let \(G=K_{m}\square K_{n}\) such that \( m \le n \) and \( n\ge 3 \), then

(1) : When the last vertex in the process of obtaining the process of obtaining \( d_{r}(C) \) in Theorem 11 is added to the graph, we have \( d_{r}(C)=\vert E(G) \vert -dim(C(G))+r \). As \( K_{m}\square K_{n} \) is \( (m+n-2) \)-regular, the code is r-MDS for

$$\begin{aligned} \frac{mn(m+n)}{2}-2mn-m-n+5\le r \le \frac{mn(m+n)}{2}-2mn+1 . \end{aligned}$$

(2) : This is straightforward from the proof of Theorem 11.

(3), (4) : These follow from Theorem 11 and Lemma 1. \(\square \)

Theorem 12

Let \(G=K_{m}\square K_{n}\) such that \( m \le n \) and \( n\ge 3 \). Then for any \(1 \le r\le m+n-2\),

$$\begin{aligned} d_{r}(C^{\bot })=r(m+n-a-2)-a{n \atopwithdelims ()2}-n{a \atopwithdelims ()2}-{r-an \atopwithdelims ()2}+a^{2}n, \end{aligned}$$

where a is the minimum integer satisfying \(r \ge an\).

Proof

By Theorem 5, \( C^{\bot }=C^{\bot }(G) \) is a \([\frac{mn(m+n)}{2}-mn,mn-1,m+n-2]\) binary code, as \( \lambda (G)=\delta (G)=m+n-2 \) and G is super-\( \lambda \). It follows from Theorem 6, we should find the rth edge connectivity to obtain \( d_{r}(C^{\bot }) \). As graph is regular, removing the edges incident to any r vertices results in a graph with \( r+1 \) components. Suppose that \( V(K_{m})=\{u_{1},u_{2},\dots ,u_{m}\} \) and \( V(K_{n})=\{v_{1},v_{2},\dots ,v_{n}\}\). We consider the same partition of vertices as in the proof of Theorem 11. Clearly \(d_{1}(C^{\bot })=\lambda (G)=m+n-2 \). Since \( \vert C_{i} \vert =n \) for \( 1 \le i \le m \), it is enough to find the maximum a satisfying \( r \ge an\). Hence, the edges incident to the first a sets of the partition should be removed. Based on the properties of partition, the vertices of each set form a clique and each of them has one neighbor in every previous set. So they have some common edges. The number of these edges is equal to \(a{n \atopwithdelims ()2}+n{a \atopwithdelims ()2}\) for \( 0 \le a \le m \). Let \( b=r-an \) be the number of vertices in the \((a+1)\) th set whose edges should be also removed to get \( \lambda _{r}(G) \). These vertices have \(a(r-an)+{r-an \atopwithdelims ()2}\) common edges with each other and vertices of previous sets. Hence for obtaining \( d_{r}(C^{\bot }) \), we should subtract the number of common edges of these r vertices from \( r(m+n-2) \). Therefore,

$$\begin{aligned} d_{r}(C^{\bot })=\lambda _{r}(G)&=r(m+n-2)-a{n \atopwithdelims ()2}-n{a \atopwithdelims ()2}-a(r-an)-{r-an \atopwithdelims ()2}\\&=r(m+n-a-2)-a{n \atopwithdelims ()2}-n{a \atopwithdelims ()2}-{r-an \atopwithdelims ()2}+a^{2}n. \end{aligned}$$

\(\square \)

Example 2

Let \( G=K_{3}\square K_{4} \). For binary linear code C(G), we have \( d_{6}(C)=12\), where \( a=1 \) and \( b=3 \). We also have \( d_{17}(C)=28 \) such that \( a=2 \) and \( b=4 \). For binary linear code \( C^{\bot }(G)\), we have \( d_{3}(C^{\bot })=12 \) and \( d_{11}(C^{\bot })=30 \), where \( a=0 \) and \( a=2\), respectively. Moreover, the code C(G) is r-MDS for \(16 \le r \le 19 \) and \( d_{r}(C) \) meets the Griesmer-type bound and the Plotkin-type bound for \( 1\le r\le 3 \) and for \( 18\le r\le 19 \), respectively.

5 GHWs of codes arising from grid graphs

This section is devoted to the rth generalized Hamming weight of the binary linear code arising from the incidence matrix of a grid.

Theorem 13

Let G be a grid \( P_{m}\square P_{n} \) and \(m \le n \) and c be the maximum integer satisfying \( r \ge (c-1)^{2} \). Then for any \(1 \le r\le mn-m-n+1\),

  1. (1)

    If \( 1 \le r \le (m-1)^{2} \), then

    1. (a)

      \( d_{1}(C)=4 \);

    2. (b)

      If \( (c-1)^{2}+1\le r \le (c-1)^{2}+\lfloor \frac{2c-1}{2}\rfloor \), then \( d_{r}(C)=2r+2c-1 \);

    3. (c)

      If \( (c-1)^{2}+\lceil \frac{2c-1}{2}\rceil \le r \le c^{2}\), then \(d_{r}(C)=2r+2c \).

  2. (2)

    If \( r\ge (m-1)^{2}+1 \), then \( d_{r}(C)=2r+2m+a-1 \), where a is the maximum integer satisfying \( r > (m-1)(m+a-1)\).

Proof

By Theorem 4, \( C=C(G) \) is a \( [2mn-m-n, mn-m-n+1,4] \) binary code, as \( g(G)=4 \). Let \( V(P_{m})=\{u_{1},u_{2},\dots ,u_{m}\} \) and \( V(P_{n})=\{v_{1},v_{2},\dots ,v_{n}\}\). We consider a partition \(D_{1}\cup D_{2} \) of vertices of G, where \(D_{1}=\{C_{1}, C_{2}, \dots , C_{m-1}\}\) is a partition of \( V( P_{m}\square P_{m}) \) and \( D_{2}=\{C_{m},C_{m+1}, \dots , C_{n-1}\}\) is a partition of \( V( P_{m}\square P_{n-m}) \). The set \( C_{1}\) contains the vertices of \( P_{2}\square P_{2} \), so \( \vert C_{1} \vert =4 \) and the vertices form a square. For \(2\le i \le m-1\), \( C_{i} \) contains the remaining vertices of \( P_{i+1}\square P_{i+1} \) which are the vertices of \( P_{2i+1} \) connected to \( P_{i}\square P_{i} \), hence \( \vert C_{i} \vert =2i+1 \) and each two consecutive vertices of every set are adjacent and each of them except the \( (i+1) \)th one also has one neighbor in the previous set (see Fig. 1). For \( m\le i \le n-1 \), we have \( C_{i}=\{(u_{j},v_{i+1}): 1\le j \le m \} \), so \(\vert C_{i} \vert =m \). We see that each vertex of every set is incident to the previous one and also has one neighbor in the previous set. By Remark 2, let D be a subcode of C(G) such that \( \vert \chi (D)\vert =d_{r}(C) \). Hence, there exists a subgraph H of G such that \( dim(C(H))=r =m'-n'+c'\), where \( m' \) and \( n' \) are the size and order of H, respectively. Therefore, \( d_{r}(C)=m' \). We construct the subgraph H by adding the vertices of the set \( C_{1} \) and then the set \( C_{2} \) according to the order in which they are placed in these sets. Therefore, H is connected and \( c'=1 \). Let \( H'=P_{c}\square P_{c} \), where \( c \le m \). So \( V(H')=\cup _{i=1}^{c-1}C_{i} \). Then, \( H' \) has exactly \( n_{c}=c^{2} \) vertices and \( m_{c}=2c^{2}-2c \) edges. Hence, \( dim(C(H'))= m_{c}- n_{c}+1=(c-1)^{2}\), as \( H' \) is connected. Therefore, H has at least \( n_{c} \) vertices and \(m_{c}\) edges. So first we find the maximum c satisfying \( r \ge (c-1)^{2} \). Based on the values of r, the proof is divided into two cases:

Case 1 If \( 1 \le r \le (m-1)^{2} \), the maximum occurs when \( H=P_{m}\square P_{m} \) and has at most \(D_{1}=\cup _{i=1}^{m-1}C_{i} \) vertices. So we consider three cases:

  1. (1)

    \( d_{1}(C)=4 \), as \( \vert C_{1} \vert =4 \);

  2. (2)

    If \( (c-1)^{2}+1\le r \le (c-1)^{2}+\lfloor \frac{2c-1}{2}\rfloor \), then the subgraph H has \( n_{c}+b \) vertices and \( m_{c}+2b-1 \) edges, where \( b \le c \) and \( r= c^{2}-2c+b\). Therefore,

    $$\begin{aligned} d_{r}(C)=\vert E(H)\vert =r+c^{2}+b-1=2r+2c-1 ; \end{aligned}$$
  3. (3)

    If \( (c-1)^{2}+\lceil \frac{2c-1}{2}\rceil \le r \le c^{2}\), then the subgraph H has \( n_{c}+b+c \) vertices and \( m_{c}+2c-1+2b-1=m_{c}+2b+2c-2 \) edges, where \( b \le c+1 \) and \( r= c^{2}+b-c-1\). Therefore,

    $$\begin{aligned} d_{r}(C)=\vert E(H)\vert =r+c^{2}+c+b-1=2r+2c . \end{aligned}$$
Fig. 1
figure 1

The process of adding vertices and edges to get \( P_{m}\square P_{m} \) (from left to right \( P_{2}\square P_{2} \), \( P_{3}\square P_{3} \), \( P_{4}\square P_{4} \),..., \( P_{m}\square P_{m} \))

Case 2 If \( r\ge (m-1)^{2}+1 \), the subgraph \(H''\) of G such that \( V(H'')=\cup _{i=1}^{(m-1)+a}C_{i} \), where \(0 \le a \le n-m \), has exactly \( n_{a}=m^{2}+am \) vertices and \( m_{a} \) edges, where \( m_{a}= 2m^{2}-2m+a(2m-1)\). Since each \( C_{i} \) for \( m\le i \le n-1 \) has m vertices and \( 2m-1 \) edges. So we should find the maximum a such that \( dim(C(H''))=m_{a}-n_{a}+1 < r \) in order to determine \( d_{r}(C) \), as \( H'' \) is connected. Hence, the subgraph H of G has at least \( n_{a} \) vertices and \( m_{a} \) edges. Now we find the integer b, which is actually the number of required vertices from the \( (a+m) \)th set, such that \( r=dim(C(H''))+2b-1-b=(m-1)^{2}+a(m-1)+b-1\). Therefore,

$$\begin{aligned} d_{r}(C)=\vert E(H)\vert =r+m^{2}+am+b-1=2r+2m+a-1. \end{aligned}$$

\(\square \)

Corollary 3

If \( G=P_{m}\square P_{n} \) and \(m \le n \), then

  1. (1)

    The code C(G) is a r-MDS code for \( r= mn-m-n+1. \)

  2. (2)

    The code C(G) satisfies the chain condition.

  3. (3)

    \( d_{r}(C) \) meets the Griesmer-type bound for \( r=1 \).

  4. (4)

    \( d_{r}(C) \) meets the Plotkin-type bound for \( r=1 \) when \(G=P_{2}\square P_{3} \) and for \( r=k \) for all m and n.

Proof

Let \( G=P_{m}\square P_{n} \) and \(m \le n \), then

(1) : Based on the result of Theorem 13, it can be seen when the last vertex in the process of obtaining \( d_{r}(C) \) is added to the graph, we have \( d_{r}(C)=\vert E(G) \vert -dim(C(G))+r \). As the last vertex is of degree two, the code is r-MDS for \( r= mn-m-n+1\).

(2) : This is straightforward from the proof of Theorem 13.

(3), (4) : These follow from Theorem 13 and Lemma 1.

\(\square \)

Theorem 14

Let \( G=P_{m}\square P_{n} \) and \(m \le n \). Then for any \(1 \le r\le mn-1\),

  1. (1)

    If \(1\le r\le mn-m\), then \( d_{r}(C^{\bot }) = 2r-a \), where a is the maximum integer satisfying \(r\ge am\).

  2. (2)

    If \(mn-m+1\le r \le mn-1\), then \(d_{r}(C^{\bot }) = r+mn-m-n+1 \).

Proof

By Theorem 5, \( C^{\bot }=C^{\bot }(G) \) is a \([2mn-m-n,mn-1,2]\) binary code, as \( \lambda (G)=\delta (G)=2 \) and G is super-\( \lambda \). It follows from Theorem 6 that we should find the rth edge connectivity of graph. Clearly \( d_{1}(C^{\bot })=\lambda (G)=2\). Let \( V(P_{m})=\{u_{1},u_{2},\dots ,u_{m}\} \) and \( V(P_{n})=\{v_{1},v_{2},\dots ,v_{n}\}\). For obtaining \(d_{r}(C^{\bot })\), we consider a partition \( \{C_{1}, C_{2},\dots , C_{n}\} \) such that \( C_{j}=\{(u_{i},v_{j}): 1\le i \le m\} \) for \( 1\le j \le n \). The vertices of each set construct \( P_{1}\square P_{m}= P_{m} \) and each of them also has a neighbor in the previous set. There are two cases to find \( d_{r}(C^{\bot }) \):

Case 1 Suppose that \(1\le r\le mn-m\). Then, the edges incident to at most the first \( (n-1) \) sets of the partition should be removed to get the rth edge connectivity. Since \( \vert C_{j} \vert =m \) for \( 1 \le j \le n \), it is enough to find the maximum a satisfying \( r \ge am\). Hence, we should remove the edges incident to the first a sets of the partition. As during this process, two edges incident to the first \( (m-1) \) vertices of each set and one edge incident to the last vertex of each set will be removed, \( d_{am}(C^{\bot })= (2(m-1)+1)a=(2m-1)a \). Hence, \(d_{r}(C^{\bot })=\lambda _{r}(G)= (2m-1)a+2(r-am)=2r-a \), where \( 0 \le a \le n-1 \).

Case 2 Suppose that \(mn-m+1\le r \le mn-1\). Then, the edges incident to at most all vertices of graph should be removed to get the rth edge connectivity. As one edge incident to each vertex of the last set will be removed,

$$\begin{aligned} d_{r}(C^{\bot })=\lambda _{r}(G)=2mn-m-n-(mn-1-r)=r+mn-m-n+1. \end{aligned}$$

\(\square \)

Example 3

Let \( G= P_{4}\square P_{8}\). For binary linear code C(G), we have \( d_{5}(C)=15\) and \( d_{8}(C)=22 \), where \( c=3\). Moreover, \( d_{12}(C)=31 \) and \( d_{17}(C)=43 \), where \( a=0 \) and \( a=2 \), respectively. For binary linear code \( C^{\bot }(G)\), we have \( d_{11}(C^{\bot })=20 \), where \( a=2 \) and \( d_{30}(C^{\bot })=51 \). The code C(G) is r-MDS for \(r=21 \) and \( d_{r}(C) \) meets the Griesmer-type bound and the Plotkin-type bound for \( r=1 \) and for \( r=21 \), respectively.

6 GHWs of codes arising from \( C_{m}\square P_{n} \)

In this part, our concern is to find the rth generalized Hamming weight of the binary linear code derived from the Cartesian product of a cycle and a path.

Theorem 15

Let G be \( C_{m}\square P_{n} \). Then for any \(1 \le r\le mn-m+1\),

  1. (1)

    If \( m=3 \), then \( d_{r}(C)=r+3a+b-1\), where a is the maximum integer such that the inequality \(3a-2\le r\) holds and b is the minimum integer satisfying \(3a+b-3 \ge r\). Whenever \(r=3a-2\), then \( b=0 \).

  2. (2)

    For \( m>4 \), if \( 1 \le r\le (m-3)min\{m-3,n\}-m+3 \), let c be the maximum integer satisfying \( r \ge (c-1)^{2} \). Then,

    1. (a)

      If \(1 \le r \le (min\{m-3,n\}-1)^{2} \), then

      1. i.

        \( d_{1}(C)=4 \);

      2. ii.

        If \((c-1)^{2}+1 \le r \le (c-1)^{2}+\lfloor \frac{2c-1}{2}\rfloor \), then \( d_{r}(C)=2r+2c-1 \);

      3. iii.

        If \((c-1)^{2}+\lceil \frac{2c-1}{2}\rceil \le r \le c^{2}\), then \( d_{r}(C)=2r+2c \).

    2. (b)

      If \( r \ge (min\{m-3,n\}-1)^{2}+1 \), then \( d_{r}(C)=2r+2min\{m-3,n\}+a-1 \), where a is the maximum integer satisfying

      $$\begin{aligned} r>(min\{m-3,n\}-1)(min\{m-3,n\}+a-1) . \end{aligned}$$
  3. (3)

    For \( r=1 \), when \( m=4 \) and for \( m>4 \), if

    $$\begin{aligned} (m-3)min\{m-3,n\}-m+4 \le r \le m(min\{m-3,n\}-1)+1, \end{aligned}$$

    then

    $$\begin{aligned} d_{r}(C)=r+(m-2)min\{m-3,n\}+2a+b-1 , \end{aligned}$$

    where a is the maximum integer satisfying \( (m-3)min\{m-3,n\}-m+3a+1 \le r \) and b is the minimum integer such that

    $$\begin{aligned} (m-3)min\{m-3,n\}-m+3a+{b+1 \atopwithdelims ()2}+1 \ge r . \end{aligned}$$
  4. (4)

    For \( 2 \le r \le mn-m \), when \( m=4 \) and for \( m^{2}-4m+2 \le r \le mn-m \) when \( m>4 \) and \( n>m-3 \), then \( d_{r}(C)=r+m^{2}+m(a-3)+b-1 \), where a is the maximum integer satisfying \( m^{2}+m(a-4)+1 \le r \) and b is the minimum integer such that the inequality \(m^{2}+m(a-4)+b \ge r \) holds.

  5. (5)

    \(d_{mn-m+1}(C)=2mn-m.\)

Proof

It follows from Theorem 4 that \( C=C(G) \) is a \( [2mn-m, mn-m+1] \) binary code. Let \( V(C_{m})=\{u_{1},u_{2},\dots ,u_{m}\} \) and \( V(P_{n})=\{v_{1},v_{2},\dots ,v_{n}\}\). According to the values of m and r, the proof is divided into five cases:

  1. (1)

    If \(m =3 \), we consider a partition \(\{C_{1}, C_{2},\dots , C_{n}\} \) of vertices of G such that \( C_{j}=\{(u_{i},v_{j}): 1\le i \le 3\} \) for \( 1\le j \le n \). Actually, each set contains the vertices of \(C_{3}\square P_{1} \), so \( \vert C_{j} \vert =3 \). The vertices of each set form a cycle of length three and each of them also has one neighbor in the previous set. By Remark 2, let D be a subcode of C(G) such that \( \vert \chi (D)\vert =d_{r}(C) \). Hence, there exists a subgraph H of G such that \( dim(C(H))=r =m'-n'+c'\), where \( m' \) and \( n' \) are the size and order of H, respectively. Therefore, \( d_{r}(C)=m' \). We construct the subgraph H by adding the vertices of the set \( C_{1} \) and then the sets \( C_{j+1} \) for \( 1 \le j \le n-1 \) according to the order in which they are placed in these sets. Therefore, H is connected and \( c'=1 \). Let \( H'\) be a subgraph of G such that \( V(H')= \cup _{j=1}^{a}C_{a}\) for \( 1 \le a < n-1 \), then \( H' \) has exactly \( n_{a}=3a \) vertices and \( m_{a}=3(a-1)+3a=6a-3 \) edges. Hence, \( dim(C(H'))= m_{a}- n_{a}+1=3a-2\), as \( H' \) is connected. Therefore, the subgraph H has \( n_{a} \) vertices and \(m_{a}\) edges. Hence, we should find the maximum integer a satisfying \( m_{a}- n_{a}+1 \le r \). Now we should determine the number of the required vertices, denoted by b, from the \((a+1)\)th set. So it is enough to find the minimum integer b such that the inequality \( dim(C(H'))+2b-1-b=3a+b-3 \ge r \) holds. Therefore,

    $$\begin{aligned} d_{r}(C)=\vert E(H)\vert =r+3a+b-1. \end{aligned}$$
  2. (2)

    For \( m>4 \), if \( 1 \le r\le (m-3)min\{m-3,n\}-m+3 \), then the subgraph H from Remark 2 has at most \( (m-2)min\{m-3,n\} \) vertices and

    $$\begin{aligned} 2(m-2)min\{m-3,n\}-min\{m-3,n\}-m+2 \end{aligned}$$

    edges, so when the maximum occurs, \( H=P_{m-2}\square P_{min\{m-3,n\}} \). Therefore, the proof is similar to Theorem 13.

  3. (3)

    For \( r=1 \), when \( m=4 \) and for \( m>4 \), if

    $$\begin{aligned} (m-3)min\{m-3,n\}-m+4 \le r \le m(min\{m-3,n\}-1)+1, \end{aligned}$$

    then the subgraph H obtained from Remark 2 has at least \( n'' \) vertices and \( m'' \) edges, where

    $$\begin{aligned} n''= (m-2)min\{m-3,n\} \end{aligned}$$

    and

    $$\begin{aligned} m''=2(m-2)min\{m-3,n\}-min\{m-3,n\}-m+2 . \end{aligned}$$

    Now let \( C_{j}=\{(u_{m-1},v_{j}), (u_{m},v_{j}): 1\le j \le min\{m-3,n\} \} \) be a partition of some vertices. We construct the subgraph H by adding the vertices of the set \( C_{1} \) and then the sets \( C_{j+1} \) for \( 1\le j < min\{m-3,n\}-1 \) to the graph \( P_{m-2}\square P_{min\{m-3,n\}} \) according to the order in which they are placed in these sets. Therefore, H is connected and \( c'=1 \). Suppose that \( H'\) is a subgraph of G such that \( V(H')= V(P_{m-2}\square P_{min\{m-3,n\}})\cup (\cup _{j=1}^{a}C_{a})\), then \( H' \) has exactly \( n_{a}=n''+2a \) vertices and \(m_{a} \) edges, where

    $$\begin{aligned} m_{a}=m''+5a-2=(2m-5)min\{m-3,n\}-m+5a . \end{aligned}$$

    Hence,

    $$\begin{aligned} dim(C(H'))= m_{a}- n_{a}+1=(m-3)min\{m-3,n\}-m+3a+1, \end{aligned}$$

    as \( H' \) is connected. Therefore, the subgraph H has at least \( n_{a} \) vertices and \(m_{a}\) edges. Hence, we should find the maximum integer a satisfying \( m_{a}- n_{a}+1 \le r \). Now we should determine the number of the required vertices, denoted by b, from the \((a+1) \)th set. So it is enough to find the minimum integer b such that the inequality

    $$\begin{aligned} dim(C(H'))\!+\!{b+1 \atopwithdelims ()2}\!=\!(m-3)min\{m-3,n\}-m+3a\!+\!{b+1 \atopwithdelims ()2}+1 \!\ge \! r \end{aligned}$$

    holds. Therefore,

    $$\begin{aligned} d_{r}(C)=\vert E(H)\vert =r+(m-2)min\{m-3,n\}+2a+b-1. \end{aligned}$$
  4. (4)

    For \( 2 \le r \le mn-m \), when \( m=4 \) and for \( m^{2}-4m+2 \le r \le mn-m \) when \( m>4 \) and \( n>m-3 \), then the subgraph H from Remark 2 has at least \( n''=m(m-3)\) vertices and \( m''=2m^{2}-7m \) edges. Now let

    $$\begin{aligned} C_{k}=\{(u_{i},v_{k}): 1\le i \le m \} \end{aligned}$$

    for \( m-2\le k \le n \) be a partition of some vertices. We construct the subgraph H by adding the vertices of the set \( C_{m-2} \) and then the sets \( C_{m-2+k'} \) for \( 1\le k'< n-m+2 \) to the graph \( C_{m}\square P_{m-3} \) according to the order in which they are placed in these sets. Therefore, H is connected and \( c'=1 \). Let \( H'\) be a subgraph of G such that \( V(H')= V(C_{m}\square P_{m-3})\cup (\cup _{k=m-2}^{m-2+a}C_{k})\) for \( 1\le a < n-m+2 \), then \( H' \) has exactly \( n_{a}=n''+am \) vertices and \( m_{a}=m''+2am=2m^{2}+m(2a-7)\) edges. Hence, \( dim(C(H'))= m_{a}- n_{a}+1=m^{2}+m(a-4)+1\), as \( H' \) is connected. Therefore, the subgraph H has at least \( n_{a} \) vertices and \(m_{a}\) edges. Hence, we should find the maximum integer a satisfying \( dim(C(H')) \le r \). Now let b be the number of required vertices from the \((a+1) \)th set. So it is enough to find the minimum integer b such that the inequality \( dim(C(H'))+2b-1-b=m^{2}+m(a-4)+b\ge r \) holds. Therefore,

    $$\begin{aligned} d_{r}(C)=r+m^{2}+m(a-3)+b-1 . \end{aligned}$$
  5. (5)

    When \(r=mn-m+1 \), since we add the edge \( (u_{1},v_{n})(u_{m},v_{n})\), the subgraph H from Remark 2 is actually graph G. Hence,

    $$\begin{aligned} d_{mn-m+1}(C)=2mn-m. \\ \end{aligned}$$

    \(\square \)

Corollary 4

If \( G=C_{m}\square P_{n} \), then

  1. (1)

    The code C(G) is a r-MDS code for \(mn-m \le r \le mn-m+1 \).

  2. (2)

    The code C(G) satisfies the chain condition.

  3. (3)

    \( d_{r}(C) \) meets the Griesmer-type bound for \( r=1 \).

  4. (4)

    \( d_{r}(C) \) meets the Plotkin-type bound for \( r=k-1 \) when m and n have the values in Table 2 and for \(r=k \) for all m and n.

Table 2 The values of m and n for \( r=k-1 \)

Proof

Let \( G=C_{m}\square P_{n} \), then

(1) : By considering the values of \( d_{r}(C) \), it can be seen when the last vertex in the process of obtaining \( d_{r}(C) \) in Theorem 15 is added to the graph, we have \( d_{r}(C)=\vert E(G) \vert -dim(C(G))+r \). As the last vertex is of degree three, the code is r-MDS for \( r=mn-m\) and \( r=mn-m+1\).

(2) : This is straightforward from the proof of Theorem 15.

(3), (4) : These follow from Theorem 15 and Lemma 1. \(\square \)

Theorem 16

Let \( G=C_{m}\square P_{n} \). Then for any \(1 \le r\le mn-1\),

$$\begin{aligned}d_{r}(C^{\bot }) = \left\{ \begin{array}{l l l} 2r+1 &{} \quad \text{ if } (a-1)m+1\le r\le am-1 \text{ for } 1\le a\le n-1\text{, }\\ 2r &{} \quad \text{ if } \text{ r=am } \text{ for } 1\le a\le n-1\text{, }\\ r+mn-m+1 &{} \quad \text{ if } mn-m+1\le r \le mn-1\text{. } \\ \end{array} \right. \end{aligned}$$

Proof

By Theorem 5, \( C^{\bot }=C^{\bot }(G) \) is a \([2mn-m,mn-1,3]\) binary code, as \( \lambda (G)=\delta (G)=3 \) and G is super-\( \lambda \). By Theorem 6, we should find the rth edge connectivity to obtain \( d_{r}(C^{\bot }) \). Let \( V(C_{m})=\{u_{1},u_{2},\dots ,u_{m}\} \) and \( V(P_{n})=\{v_{1},v_{2},\dots ,v_{n}\}\). We consider a partition \( \{C_{1}, C_{2},\dots , C_{n}\} \) such that \( C_{j}=\{(u_{i},v_{j}): 1\le i \le m\} \) for \( 1\le j \le n \). The vertices of each set construct \( P_{1}\square C_{m}=C_{m} \) and each of them also has a neighbor in the previous set. Clearly \( d_{1}(C^{\bot })=\lambda (G)=3\). Since \( \vert C_{j} \vert =m \) for \( 1 \le j \le n \), it is enough to find the maximum a satisfying \( r \ge am\). Hence, we should remove the edges incident to the first a sets of the partition. During this process, three edges incident to the first vertex of each set and two edges incident to the next \( (m-2) \) vertices of each set and one edge incident to the last vertex of each set will be removed. In the last set, two edges incident to the first vertex and one edge incident to other vertices of the last set will be removed. According to the partition of vertices, there are three cases to obtain \( d_{r}(C^{\bot }) \):

Case 1 Suppose that \( r=am \). Then, the edges incident to the first a sets of the partition should be removed to get the rth edge connectivity. Therefore for \( 1 \le a \le n-1 \)

$$\begin{aligned} d_{r}(C^{\bot })=\lambda _{r}(G)= (3+2(m-2)+1)a=2am=2r ; \end{aligned}$$

Case 2 Suppose that \((a-1)m+1\le r\le am-1 \) for \(1\le a\le n-1\). Then, the edges incident to the first a sets of the partition and \( b=r-am \) vertices of the \( (a+1) \)th set should be removed to get the rth edge connectivity. Therefore,

$$\begin{aligned} d_{r}(C^{\bot })=\lambda _{r}(G)=2am+3+2(r-am-1)=2r+1; \end{aligned}$$

Case 3 Suppose that \(mn-m+1\le r \le mn-1\). Then, the edges incident to at most all vertices of graph should be removed to get the rth edge connectivity. Therefore,

$$\begin{aligned} d_{r}(C^{\bot })=\lambda _{r}(G)=2mn-m-(mn-1-r)=r+mn-m+1. \end{aligned}$$

\(\square \)

Example 4

Let \( G=C_{4}\square P_{5}\). For binary linear code C(G), we have \( d_{12}(C)=27\), where \( a=2 \) and \( b=4 \). For \( G=C_{5}\square P_{4}\), when \( a=1 \) and \( b=2 \), we have \( d_{5}(C)=14 \) and \( d_{12}(C)=28 \). Suppose \( G=C_{8}\square P_{4} \), we have \( d_{24}(C)=55 \), where \( a=3 \) and \( b=2 \). For binary linear code \( C^{\bot }(G)\) when \(G=C_{4}\square P_{5}\), we have \( d_{11}(C^{\bot })=23 \), \( d_{16}(C^{\bot })=32 \) and \( d_{18}(C^{\bot })=35\). The code C(G) when \(G=C_{4}\square P_{5}\) is r-MDS for \(16 \le r \le 17 \). \( d_{r}(C) \) meets the Griesmer-type bound for \( r=1 \) and meets the Plotkin-type bound for \(16 \le r \le 17 \).

7 GHWs of codes arising from \(C_{m}\square C_{n}\)

In this last section, we find the rth generalized Hamming weight of the binary linear code C whose parity check matrix is the incidence matrix of the Cartesian product of two cycles.

Theorem 17

Let G be \( C_{m}\square C_{n} \) and \(m \le n\). Then

  1. (1)

    When \( m=3 \), if \( 1\le r \le 3n-5 \), then \( d_{r}(C)=r+3a+b-1 \), where a is the maximum integer such that the inequality \(3a-2\le r\) holds and b is the minimum integer satisfying \(3a+b-3 \ge r\). Whenever \(r=3a-2\), then \( b=0 \);

  2. (2)

    For \( m>4 \), if \( 1 \le r \le m^{2}-7m+12 \), let c be the maximum integer satisfying \( r \ge (c-1)^{2} \). Then,

    1. (a)

      If \(1 \le r \le (m-4)^{2} \), then

      1. (i)

        \( d_{1}(C)=4 \);

      2. (ii)

        If \((c-1)^{2}+1 \le r \le (c-1)^{2}+\lfloor \frac{2c-1}{2}\rfloor \), then \( d_{r}(C)=2r+2c-1 \);

      3. (iii)

        If \((c-1)^{2}+\lceil \frac{2c-1}{2}\rceil \le r \le c^{2}\), then \( d_{r}(C)=2r+2c \).

    2. (b)

      If \(r \ge (m-4)^{2}+1 \), then \( d_{r}(C)=2r+2m+a-7\), where a is the maximum integer satisfying \(r>(m-4)(a+m-4) \).

  3. (3)

    For \( r=1 \), when \( m=4 \) and for \( m>4 \), if \( m^{2}-7m+13 \le r \le m^{2}-4m+1 \), then \( d_{r}(C)=r+m^{2}-5m+2a+b+5 \), where a is the maximum integer satisfying \( m^{2}-7m+3a+10 \le r \) and b is the minimum integer such that the inequality \(m^{2}-7m+3a+{b+1 \atopwithdelims ()2}+10 \ge r \) holds.

  4. (4)

    For \( 2 \le r \le mn-2m \), when \( m=4 \) and for \( m>4 \), if \( m^{2}-4m+2 \le r \le mn-2m \), then \( d_{r}(C)=r+m^{2}+m(a-3)+b-1 \), where a is the maximum integer satisfying \( m^{2}+m(a-4)+1 \le r \) and b is the minimum integer such that the inequality \(m^{2}+m(a-4)+b \ge r \) holds.

  5. (5)

    \(d_{mn-2m+1}(C)=2mn-3m.\)

  6. (6)

    If \( mn-2m+2\le r \le mn \), then \( d_{r}(C)=r+mn-m+b-1 \), where b is the minimum integer satisfying \(mn-2m+2b \ge r\).

  7. (7)

    \(d_{mn+1}(C)=2mn.\)

Proof

By Theorem 4, \( C=C(G) \) is a \( [2mn, mn+1] \) binary code. Let \( V(C_{m})=\{u_{1},u_{2},\dots ,u_{m}\} \) and \( V(C_{n})=\{v_{1},v_{2},\dots ,v_{n}\}\). The partition of vertices is analogous to Theorem 15, except that each vertex of the last set \( C_{n} \) also has a neighbor in the first set. Based on the values of m and r, the proof is divided into seven cases. The proofs of Case (1) to Case (5) are similar to Theorem 15. Now let \( mn-2m+2\le r \le mn \). Then, the subgraph H has at least \(n''=mn-m\) vertices and \(m''=2mn-3m\) edges. Let b be the number of required vertices from the last set to get \( d_{r}(C) \), therefore H is connected and \( c'=1 \). As each vertex of \( \{(u_{i},v_{n}): 1\le i \le m \} \) has two neighbors in \( C_{m}\square P_{n-1} \) and also \( (u_{i},v_{n})\) is adjacent to \((u_{i+1},v_{n}) \), so it is enough to determine the minimum integer b satisfying \(m''-n''+2b+b-1-b+1=mn-2m+2b \ge r\). Therefore,

$$\begin{aligned} d_{r}(C)=r+m(n-1)+b-1=r+mn-m+b-1 . \end{aligned}$$

When \( r=mn+1 \), the subgraph H from Remark 2 is actually graph G, as we add the edge \( (u_{1},v_{n})(u_{m},v_{n}) \). Hence

$$\begin{aligned} d_{mn+1}(C)=2mn. \end{aligned}$$

\(\square \)

Corollary 5

If \( G=C_{m}\square C_{n} \) and \(m \le n\), then

  1. (1)

    The code C(G) is a r-MDS code for \( mn-1 \le r \le mn+1. \)

  2. (2)

    The code C(G) satisfies the chain condition.

  3. (3)

    \( d_{r}(C) \) meets the Griesmer-type bound for \( r=1 \).

  4. (4)

    \( d_{r}(C) \) meets the Plotkin-type bound for \( r=k-1 \) based on the values of m and n in Table 3, and for \( r=k \) for all m and n.

Table 3 The values of m and n for \( r=k-1 \)

Proof

Let \( G=C_{m}\square C_{n} \) and \(m \le n\), then

(1) : Similar to the other graphs, when the last vertex in the process of obtaining \( d_{r}(C) \) in Theorem 17 is added to the graph, we have \( d_{r}(C)=\vert E(G) \vert -dim(C(G))+r \). As the last vertex is of degree four, the code is r-MDS for \( mn-1 \le r \le mn+1\).

(2) : This is straightforward from the proof of Theorem 17.

(3), (4) : These follow from Theorem 17 and Lemma 1. \(\square \)

Theorem 18

Let G be \( C_{m}\square C_{n} \) and \(m\le n\). Then for any \( 1 \le r \le mn-1 \)

$$\begin{aligned}d_{r}(C^{\bot }) = \left\{ \begin{array}{l l l l l} 3r+1 &{} \quad \text{ if } 1\le r \le m-1 \text{, }\\ 2r+m &{} \quad \text{ if } \text{ r=am } \text{ for } 1\le a\le n-1\text{, }\\ 2r+m+1&{} \quad \text{ if } am+1\le r \le (a+1)m-1 \text{ for } 1\le a\le n-1\text{, }\\ r+mn+1 &{} \quad \text{ if } mn-m+1\le r \le mn-1\text{. }\\ \end{array} \right. \end{aligned}$$

Proof

By Theorem 5, \( C^{\bot }=C^{\bot }(G) \) is a linear \([2mn,mn-1,4]\) binary code, as \( \lambda (G)=\delta (G)=4 \) and G is super-\( \lambda \). By Theorem 6, we should find the rth edge connectivity to obtain \( d_{r}(C^{\bot }) \). Let \( V(C_{m})=\{u_{1},u_{2},\dots ,u_{m}\} \) and \( V(C_{n})=\{v_{1},v_{2},\dots ,v_{n}\}\). We consider a partition \( \{C_{1}, C_{2},\dots , C_{n}\} \) such that \( C_{j}=\{(u_{i},v_{j}): 1\le i \le m\} \) for \( 1\le j \le n \). The vertices of each set construct \( P_{1}\square C_{m}=C_{m} \) and each of them also has a neighbor in the previous set except the vertices of the last set also has one neighbor in the first set. Clearly \( d_{1}(C^{\bot })=\lambda (G)=4\). Since \( \vert C_{j} \vert =m \) for \( 1 \le j \le n \), it is enough to find the maximum \( 1\le a \le n-1 \) satisfying \( r \ge am\). Hence, we should remove the edges incident to the first a sets of the partition. During this process, in the first set, four edges incident to the first vertex and three edges incident to the next \( (m-2) \) vertices and two edges incident to the last vertex will be removed. In the next \( (n-2) \) sets, three edges incident to the first vertex of each set, two edges incident to the next \( (m-2) \) vertices of each set and one edge incident to the last vertex of each set will be removed. In the last set, two edges incident to the first vertex and one edge incident to other vertices of the last set will be removed. Based on the partition of vertices, there are four cases to obtain \( d_{r}(C^{\bot }) \):

Case 1 Suppose that \(1\le r \le m-1 \). Then, the edges incident to at most first \((m-1) \) vertices of \( C_{1} \) should be removed to get the rth edge connectivity. Therefore,

$$\begin{aligned} d_{r}(C^{\bot })= \lambda _{r}(G)=4+3(r-1)=3r+1 . \end{aligned}$$

Case 2 Suppose that \( r=am \). Then, the edges incident to the first a sets of the partition should be removed to get the rth edge connectivity. Therefore for \( 1 \le a \le n-1 \)

$$\begin{aligned} d_{r}(C^{\bot })= & {} \lambda _{r}(G)= (4+3(m-2)+2)+(3+2(m-2)+1)(a-1)\\&\quad =m+2am=2r+m . \end{aligned}$$

Case 3 Suppose that \(am+1\le r \le (a+1)m-1\) for \(1\le a\le n-1\). Then, the edges incident to the first a sets of the partition and \( b=r-am \) vertices of the \( (a+1) \)th set should be removed to get the rth edge connectivity. Therefore,

$$\begin{aligned} d_{r}(C^{\bot })= \lambda _{r}(G)=3m+2m(a-1)+3+2(r-am-1)=2r+m+1. \end{aligned}$$

Case 4 Suppose that \(mn-m+1\le r \le mn-1\). Then, the edges incident to at most all vertices of graph should be removed to get the rth edge connectivity. Therefore,

$$\begin{aligned} d_{r}(C^{\bot })= \lambda _{r}(G)=2mn-(mn-1-r)=r+mn+1. \end{aligned}$$

\(\square \)

Example 5

Let \( G=C_{4}\square C_{5}\). For binary linear code C(G), we have \( d_{20}(C)=39 \), where \( b=4 \). When \( G=C_{5}\square C_{6}\), we have \( d_{23}(C)=49 \), where \( b=2 \). For binary linear code \( C^{\bot }(G)\) when \( G=C_{4}\square C_{5}\), we have \( d_{3}(C^{\bot })=10 \), \( d_{8}(C^{\bot })=20 \), \( d_{14}(C^{\bot })=33 \) and \( d_{18}(C^{\bot })=39 \). The code C(G) when \( G=C_{4}\square C_{5}\) is r-MDS for \(19 \le r \le 21 \). \( d_{r}(C) \) meets the Griesmer-type bound for \( r=1 \) and meets the Plotkin-type bound for \(20 \le r \le 21 \).