1 Introduction

Covering vertices or edges of a graph by the smallest number of paths is a fundamental optimization problem and appears in the literature in several variations depending upon the properties one requires from the paths. In the isometric path cover problem (alias geodetic cover problem), the aim is to cover all the vertices by a minimum number of shortest paths [4, 5, 10, 11, 15, 21]. In the path cover problem, we want to cover all the vertices by a minimum number of vertex disjoint paths [6, 7, 20]. Dual concepts have also been studied as, for instance, the k-path covers which are sets S of vertices of a graph G, such that every path of order k in G contains at least one vertex from S; see [2, 3, 9]. In the edge version of the isometric path cover problem, we want to cover all the edges by a minimum number of shortest paths [1, 22, 23]. In this paper, we are interested in the strong edge geodetic problem introduced in [17] as follows.

Let \(G = (V(G), E(G))\) be a graph. A set of vertices \(X\subseteq V(G)\) is a strong edge geodetic set if, to any pair of vertices u and v from X, we can assign a shortest uv-path \(P_{uv}\), such that every edge \(xy\in E(G)\) is contained in at least one on the paths \(P_{uv}\). The cardinality of a smallest strong edge geodetic set of G is the strong edge geodetic number \({{\,\mathrm{\mathrm sg_e}\,}}(G)\) of G. Such a set is briefly called a \({{\,\mathrm{\mathrm sg_e}\,}}(G)\)-set.

In the seminal paper [17], it was proved, among other results, that the strong edge geodetic problem is \(\mathcal{N}\mathcal{P}\)-complete. In [8], it was further proved that there is no approximation of the strong edge geodetic number with an approximation factor better that 781/780. Several additional results on the strong edge geodetic number were reported in [25, 26]. In the latter paper, the strong edge geodetic number was determined for Cartesian products \(P_n\,\square \,P_k\), where \(k\in \{2,3,4\}\).

The vertex version of the strong edge geodetic problem is known as the strong geodetic problem and was studied for the first time in [16, 18]. The strong geodetic problem is also \(\mathcal{N}\mathcal{P}\)-complete and remains such even when restricted to bipartite graphs and multipartite graphs [13]. Moreover, determining whether a given set X is a strong geodetic set is \(\mathcal{N}\mathcal{P}\)-hard [8] as well.

The strong geodetic number of complete bipartite (resp. mutipartite) graphs received a lot of attention. First, in [13], the problem was solved for balanced complete bipartite graphs \(K_{n,n}\). Subsequently, using different approaches, a formula for the strong geodetic number of arbitrary complete bipartite graphs was derived in [14] and in [12]. In [14], a lower bound for the strong geodetic number of a complete multipartite graph was given and it was conjectured that the strong geodetic number remains \(\mathcal{N}\mathcal{P}\)-complete on complete multipartite graphs. In [8], this conjecture was disproved by developing a polynomial algorithm for the strong geodetic number of complete mutipartite graphs. In this direction, we emphasize that in [19], an \(O(|E(G)|\cdot |V(G)|^2)\) algorithm for computing the strong geodetic number of an outerplanar graph G was developed. Several additional interesting results on the strong geodetic problem were presented in [24]. Among other results, relations between the strong geodetic number and the connectivity and the diameter were established, and graphs with the strong geodetic number equal to 2, \(|V(G)|-1\), and |V(G)| were characterized.

Motivated by the efforts to determine the strong geodetic number of complete bipartite graphs, we determine in Sect. 2 the strong edge geodetic number of complete bipartite graphs, and using this result, we then determine the strong edge geodetic number of arbitrary complete multipartite graphs. In Sect. 3, we characterize graphs G with \({{\,\mathrm{\mathrm sg_e}\,}}(G) = n(G)\) and discuss the graphs with \({{\,\mathrm{\mathrm sg_e}\,}}(G) = n(G)-1\). In particular, we observe that Cartesian products \(P_2\,\square \,K_n\) belong to this family of graphs. This corrects [25, Theorem 13] where it is wrongly stated that \({{\,\mathrm{\mathrm sg_e}\,}}(P_2\,\square \,K_n) = 2n-2\). We then proceed by determining \({{\,\mathrm{\mathrm sg_e}\,}}(P_m\,\square \,K_n)\) for all \(m, n\ge 2\).

We conclude the introduction by giving some definitions needed. The order of a graph G is denoted by n(G). A vertex u of a graph G is universal if \(\deg _G(u) = n(G) - 1\). The Cartesian product \(G\,\square \,H\) of graphs G and H is the graph with the vertex set \(V(G) \times V(H)\), vertices (gh) and \((g',h')\) being adjacent if either \(g=g'\) and \(hh'\in E(H)\), or \(h=h'\) and \(gg'\in E(G)\). As usual, \(\chi '(G)\) is the chromatic index of G. For a positive integer n, the set \(\{1,\ldots , n\}\) will be dented by [n].

If U is a strong edge geodetic set, then we will denote by \(\widehat{U}\) the set of associated paths with endpoints from U which cover all the edges of G. Clearly, \(\widehat{U}\) is not unique, but unless stated otherwise, we will assume that \(\widehat{U}\) has been selected and is fixed.

2 Complete Multipartite Graphs

In this section, we determine the strong edge geodetic number of complete multipartite graphs. To do so, we first prove the corresponding result for complete bipartite graphs which reads as follows.

Theorem 2.1

If \(n \ge m \ge 2\), then the following holds.

  1. (i)

    If n is even, then

    $$\begin{aligned} {{\,\mathrm{\mathrm sg_e}\,}}(K_{n,m}) = {\left\{ \begin{array}{ll} n+1; &{} n=m, \\ n; &{} n \ge m+1. \end{array}\right. } \end{aligned}$$
  2. (ii)

    If n is odd, then

    $$\begin{aligned} {{\,\mathrm{\mathrm sg_e}\,}}(K_{n,m}) = {\left\{ \begin{array}{ll} n+2; &{} n=m, \\ n+1; &{} n=m+1, \\ n; &{} n \ge m+2. \end{array}\right. } \end{aligned}$$

In the rest of the section, we assume that \(n \ge m \ge 2\) and that the bipartition of \(K_{n,m}\) is (XY), where \(X=\{x_0, \ldots , x_{n-1}\}\) and \(Y=\{y_0, \ldots , y_{m-1}\}\).

Lemma 2.2

If U is a strong edge geodetic set of \(K_{n,m}\), then \(X \subseteq U\) or \(Y \subseteq U\).

Proof

Let U be a strong edge geodetic set of the graph \(K_{n,m}\). Suppose on the contrary that there exist vertices \(x_i \in X {\setminus } U\) and \(y_j \in Y {\setminus } U\). Because \({{\,\mathrm{\mathrm diam}\,}}(K_{n,m})=2\) and \(x_iy_j\) is an edge of \(K_{n,m}\), none of the shortest paths with endpoints from U can cover the edge \(x_iy_j\), that is, U cannot be a strong edge geodetic set. \(\square \)

Lemma 2.3

If U is a strong edge geodetic set of \(K_{n,m}\) and \(Y \subseteq U\), then \(|U| \ge n+1\).

Proof

Suppose U is a strong edge geodetic set of \(K_{n,m}\), where \(U = Y \cup X'\) with \(X' \subseteq X\) and \(|X'| = k\), \(0 \le k \le n\). Consider an arbitrary vertex \(y_j \in Y\). There are exactly \(n-k\) edges between \(y_j\) and \(X {\setminus } X'\). Because the shortest paths that cover these edges have both of their endpoints in Y, it has to hold \(m-1 \ge n-k\). This in turn implies that \(|U| = |Y| + |X'| = m+k \ge n+1\). \(\square \)

Corollary 2.4

If \(n \ge m \ge 2\), then \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,m}) \ge n\). Moreover, if \(m=n\), then \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,n}) \ge n+1\).

Proof

If \(m=n\), then the second assertion of the corollary follows immediately from Lemmas 2.2 and 2.3. Suppose now that \(n> m\) and let U be a smallest strong edge geodetic set of \(K_{n,m}\), so that \(|U| = {{\,\mathrm{\mathrm sg_e}\,}}(K_{n,m})\). Then, \(X \subseteq U\) or \(Y \subseteq U\) by Lemma 2.2. If \(X \subseteq U\), then \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,m}) = |U| \ge |X| = n\). And, if \(Y \subseteq U\), then \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,m}) \ge n +1\) follows by Lemma 2.3. \(\square \)

We have thus established the lower bound for the case when n is even. For n odd, we proceed as follows.

Lemma 2.5

Let U be a strong edge geodetic set of \(K_{n,m}\). If n is odd and \(X \subseteq U\), then \(|U| \ge \frac{2n}{n+1} + m\).

Proof

Let U be a strong edge geodetic set of \(K_{n,m}\), where \(U=X \cup Y'\) with \(Y' \subseteq Y\) and \(|Y'| = k\). For each edge xy, where \(x \in X\) and \(y \in Y'\), we put the shortest path xy to \(\widehat{U}\). The edges between vertices from X and \(Y {\setminus } Y'\) must be covered by the shortest paths of length 2 with both of their endpoints in X. For each pair of vertices from X, we can put only one shortest path to \(\widehat{U}\), so we can only put \(n \atopwithdelims ()2\) shortest paths to \(\widehat{U}\) to cover the \(n \cdot (m-k)\) edges between the vertices from X and the vertices from \(Y {\setminus } Y'\). Moreover, because the degree of every vertex from \(Y {\setminus } Y'\) is n, which we have assumed to be odd, each vertex from \(Y {\setminus } Y'\) must be the central vertex of at least \((n+1)/2\) shortest paths from \(\widehat{U}\). Since U is a strong edge geodetic set this implies that \({n \atopwithdelims ()2} \ge (m-k) \cdot \frac{n+1}{2}\). This inequality rewrites to \(k \ge m - n(n-1)/(n+1)\) which in turn implies that \(|U| = n+k \ge n+m- n(n-1)/(n+1) = \frac{2n}{n+1} + m\). \(\square \)

Corollary 2.6

If \(n\ge 3\) is odd, then \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,n}) \ge n+2\) and \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,n-1}) \ge n+1\).

Proof

Let U be a smallest strong edge geodetic set of \(K_{n,n}\). By Lemma 2.5

$$\begin{aligned} |U| \ge n + \frac{2n}{n+1}. \end{aligned}$$

As |U| is an integer and \(2n/(n+1) > 1\) for \(n\ge 2\), we get \(|U| = {{\,\mathrm{\mathrm sg_e}\,}}(K_{n,n}) \ge n + 2\).

Let now U be a smallest strong edge geodetic set of \(K_{n,n-1}\). By Lemma 2.2, we have \(X \subseteq U\) or \(Y \subseteq U\). In the latter case, Lemma 2.3 gives \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,n-1}) \ge n+1\). Assume second that \(X \subseteq U\). Then, Lemma 2.5 gives

$$\begin{aligned} |U| \ge \frac{2n}{n+1} + (n-1) = n + \frac{n-1}{n+1}. \end{aligned}$$

Since \(\frac{n-1}{n+1} > 0\) for \(n \ge 2\) and since |U| is an integer, also in this case, we get \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,n-1}) \ge n+1\). \(\square \)

So far, we have proved the lower bound for all the cases of Theorem 2.1. In the following, we will construct in each case a strong edge geodetic set of the required cardinality.

Case 1: n is even.

We first consider \(K_{n,n}\) and prove that

$$\begin{aligned} {{\,\mathrm{\mathrm sg_e}\,}}(K_{n,n}) \le n+1\,. \end{aligned}$$
(1)

We claim that \(U = X \cup \{y_{n-1}\}\) is a strong edge geodetic set of \(K_{n,n}\). For every \(0\le i\le n-1\), add the shortest path \(x_i y_{n-1}\) to \(\widehat{U}\) to cover the edge \(x_i y_{n-1}\). Then, all the other edges must be covered by shortest paths of the form \(x_i y_j x_k\), where \(i \not =k\). To do so, we use edge-colorings of \(K_n\). It is well known that \(\chi '(K_n) = n-1\) for even n. Let \(V(K_n) = \{0,1,\ldots ,n-1\}\). Then, an edge-coloring c of \(K_n\) using \(n-1\) colors can be defined as follows: if \(i,j \in \{0,1,\ldots ,n-2\}\), \(i \not = j\), then let \(c(ij) = (i+j) \mod (n-1)\), and for for \(i \in \{0,1,\ldots ,n-2\}\) let \(c(i(n-1)) = 2i \mod (n-1)\).

In the covering of \(K_{n,n}\) that we are constructing, we put the shortest path \(x_i y_j x_k\) to \(\widehat{U}\) if and only if \(c(ik) = j\). See Fig. 1, where this construction is illustrated for the case \(n=6\) and the edges incident to \(y_2\). In \(K_6\), we have \(c(02) = c(15) = c(34) = 2\); hence, the paths \(x_0y_2x_2\), \(x_1y_2x_5\), and \(x_3y_2x_4\) belong to \(\widehat{U}\).

Fig. 1
figure 1

Shortest paths from \(\widehat{U}\) that cover edges incident to \(y_2\)

Using this construction, a pair of vertices \(x_i\) and \(x_k\) is never used twice, and for each vertex \(y \in Y {\setminus } \{y_{n-1}\}\), the shortest paths in \(\widehat{U}\) have pairwise different endpoints. Since in c every color is used exactly n/2 times, the shortest paths from \(\widehat{U}\) passing through \(y_j\) cover all the edges incident with \(y_j\). This proves (1).

Consider now \(K_{n,m}\), where \(m \le n-1\) (and n is even). We need to show that \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,m}) \le n\). For this sake, we claim that X is a strong edge geodetic set. Indeed, use the above edge-coloring c of \(K_n\) and for each \(y_i \in Y\), \(i\in \{0, \ldots , m-1\}\), put all the shortest paths \(x_j y_i x_k\) to \(\widehat{U}\) for which \(c(jk) = i\). By the above argument, X is indeed a strong edge geodetic set, and hence, \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,m}) \le n\) in this subcase.

Case 2: n is odd.

We first consider \(K_{n,n}\) and prove that \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,n}) \le n+2\). For this purpose, consider the set \(U = X \cup \{y_{n-2}, y_{n-1}\}\). The subgraph of \(K_{n,n}\) induced by the set of vertices \(V(K_{n,n}) {\setminus } \{x_{n-1}, y_{n-1}\}\) is isomorphic to \(K_{n-1,n-1}\). As \(n-1\) is even, we can cover its edges by the paths as described in Case 1 to derive (1). Recall that for this covering, the vertices \(x_0, \ldots , x_{n-1}\) and \(y_{n-2}\) are used. To cover the edges \(y_{n-1}x_i\), \(0\le i\le n-1\), add the shortest paths \(y_{n-1}x_i\) to \(\widehat{U}\). Finally, to cover the remaining yet uncovered edges, that is, the edges \(x_{n-1} y_i\), where \(i \in \{0, \ldots , n-2\}\), put the shortest paths \(x_{n-1} y_i x_i\) to \(\widehat{U}\).

We next show that \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,n-1}) \le n+1\). In this subcase, set \(U = X \cup \{y_{n-2}\}\). Then, as in the above subcase, cover the edges of the subgraph of \(K_{n,n-1}\) induced by the set of vertices \(V(K_{n,n-1}) {\setminus } \{x_{n-1}\}\) as described in Case 1 to derive (1). After that, to cover the edges \(x_{n-1} y_i\), where \(i \in \{0, \ldots , n-2\}\) we add to \(\widehat{U}\) the shortest paths \(x_{n-1} y_i x_i\).

Consider finally \(K_{n,m}\), where \(m \le n-2\). In this case, X is a strong edge geodetic set. For this sake, note that by the second subcase of Case 1, we know that \(\{x_0, \ldots , x_{n-2}\}\) is a strong edge geodetic set of the subgraph of \(K_{n,m}\) induced by the set \(V(K_{n,m}){\setminus } \{x_{n-1}\}\). To cover the remaining not yet covered edges \(x_{n-1} y_i\), where \(i \in \{0, \ldots , m-1\}\) we add to \(\widehat{U}\) the shortest paths \(x_{n-1} y_i x_i\). From here, it is clear that X is a strong edge geodetic set of \(K_{n,m}\) and we conclude that in this subcase \({{\,\mathrm{\mathrm sg_e}\,}}(K_{n,m}) \le n\).

We have thus established all the upper bounds which completes the proof of Theorem 2.1. Using it, we can in turn determine the strong edge geodetic number of complete multipartite graphs as follows.

Theorem 2.7

If \(k\ge 2\) and \(2\le n_1\le n_2\ \le \cdots \le n_k\), then the following holds.

  1. (i)

    If \(n_1\) is even, then

    $$\begin{aligned} {{\,\mathrm{\mathrm sg_e}\,}}(K_{n_1,\ldots , n_k}) = {\left\{ \begin{array}{ll} \sum \limits _{j=2}^{k} n_j + 1; &{} n_2\in \{n_1, n_1+1\}, \\ \sum \limits _{j=2}^{k} n_j; &{} \text{ otherwise }; \end{array}\right. } \end{aligned}$$
  2. (ii)

    If \(n_1\) is odd, then

    $$\begin{aligned} {{\,\mathrm{\mathrm sg_e}\,}}(K_{n_1,\ldots , n_k}) = {\left\{ \begin{array}{ll} \sum \limits _{j=2}^{k} n_j + 2; &{} n_2 = n_1, \\ \sum \limits _{j=2}^{k} n_j; &{} \text{ otherwise }. \end{array}\right. } \end{aligned}$$

Proof

Let \(k\ge 2\) and \(2\le n_1\le n_2\ \le \cdots \le n_k\), and set \(G = K_{n_1,\ldots , n_k}\) for the rest of the proof. Let \(X_i\), \(i\in [k]\), be the partition sets of G, where \(|X_i| = n_i\). Let U be an arbitrary (smallest) strong edge geodetic set of G. If \(i\ne j\), then, by Lemma 2.2, we see that \(X_i \subseteq U\) or \(X_j\subseteq U\). If follows that U contains \(k-1\) of the partite sets.

Let \(W = \cup _{i=2}^{k}X_i\). Then, it remains to cover the edges between \(X_1\) and each of the \(X_i\), \(i\ge 2\). More precisely, we need to cover the edges in induced subgraphs \(K_{n_1,n_i}\), \(i\ge 2\), where the partite sets of cardinality \(n_i\) are already included. Clearly, no shortest path of G has length greater than 2 and a shortest path of length 2 has both endpoints in the same set of the partition. Hence, an edge of \(K_{n_1, n_i}\) can be covered only by vertices in \(X_1 \cup X_i\), for every \(2 \le i \le k\).

Assume first that \(n_2 \ge n_1 + 2\). Then, by Theorem 2.1 and its proof, we infer that \(X_2\) is a strong edge geodetic set of \(K_{n_1,n_2}\) with minimum cardinality. Furthermore, since if \(k > 2\), for every \(2 < i \le k\), we have \(n_i \ge n_2 \ge n_1 + 2\), again by Theorem 2.1, we have that \(X_i\) is a strong edge geodetic set of \(K_{n_1, n_i}\) with minimum cardinality. Therefore, W is a is a strong edge geodetic set of G with minimum cardinality no matter whether \(n_1\) is even or odd. Moreover, we get the same conclusion if \(n_1\) is odd and \(n_2 = n_1 + 1\). Assume next that \(n_1\) is odd and \(n_2 = n_1\). Then, Theorem 2.1(ii) implies that the union of \(X_2\) and two vertices of \(X_1\), say u and w is a strong edge geodetic set of \(K_{n_1,n_2}\) with minimum cardinality. In this case, we conclude that \(W\cup \{u,v\}\) is a strong edge geodetic set of G with minimum cardinality. The cases when \(n_1\) is even and \(n_2\in \{n_1, n_1+1\}\) are treated similarly. \(\square \)

3 Graph with Large Strong Edge Geodetic Sets

In this section, we first characterize graphs G with \({{\,\mathrm{\mathrm sg_e}\,}}(G) = n(G)\). After that, we consider graphs G with \({{\,\mathrm{\mathrm sg_e}\,}}(G) = n(G) - 1\) and determine \({{\,\mathrm{\mathrm sg_e}\,}}(P_n\,\square \,K_m)\). In particular, \({{\,\mathrm{\mathrm sg_e}\,}}(P_2\,\square \,K_m) = 2\,m - 1\), which corrects a result from [25].

Let G be a graph and \(uv\in E(G)\). We say that a vertex v is a dominant neighbor of u if \(N[u]\subseteq N[v]\), where \(N[u] = \{u\} \cup \{x:\ ux\in E(G)\}\) is the closed neighborhood of a vertex u. Vertices u and v of a graph G are twins if \(N[u] = N[v]\). Note that twins are necessarily adjacent and that if u and v are twins, then u is a dominant neighbor of v and v is a dominant neighbor of u.

The following lemma seems to be of independent interest.

Lemma 3.1

Let G be a graph and \(U\subseteq V(G)\) be a strong edge geodetic set. If v is a dominant neighbor of u, then \(u\in U\). In particular, if u and v are twin vertices, then \(u\in U\) and \(v\in U\).

Proof

Let \(uv\in E(G)\) and \(N[u]\subseteq N[v]\). If P is a shortest path in G which contains the edge uv, then one of the endpoints of P must be u, for otherwise P would not be shortest. If further u and v are twins, then also \(N[v]\subseteq N[u]\) and thus also \(v\in U\). \(\square \)

Proposition 3.2

Let G be a graph. Then, \({{\,\mathrm{\mathrm sg_e}\,}}(G) = n(G)\) if and only if every vertex of G has a dominant neighbor.

Proof

If every vertex of G has a dominant neighbor, then every vertex lies in every strong edge geodetic set by Lemma 3.1. Hence, \({{\,\mathrm{\mathrm sg_e}\,}}(G) = n(G)\).

Assume now that a vertex \(u\in V(G)\) does not admit a dominant neighbor. We claim that \(U = V(G){\setminus } \{u\}\) is a strong edge geodetic set of G. Let v be an arbitrary neighbor of u. Since \(N[u] \not \subseteq N[v]\), there exists a vertex \(w\in N[u]{\setminus } N[v]\). To cover the edge uv, put the shortest path wuv to \(\widehat{U}\). Proceed analogously for every neigbor \(v'\) of u, where if the edge \(v'u\) has been already covered before, do nothing. In this way, all edges incident with u are covered. Let next xy be an arbitrary edge from E(G) where \(\{x, y\} \cap \{u\} = \emptyset \). Then add to \(\widehat{U}\) the shortest path xy. Clearly, the paths added so far to \(\widehat{U}\) cover all the edges of G and we conclude that \({{\,\mathrm{\mathrm sg_e}\,}}(G) < n(G)\). \(\square \)

Proposition 3.2 implies several results from [25] as for instance [25, Theorem 8] which asserts that if a graph G contains at least two universal vertices, then \({{\,\mathrm{\mathrm sg_e}\,}}(G) = n(G)\).

A vertex u of a graph G is simplicial if N(u) induces a clique of G. If u is a simplicial vertex and v its arbitrary neighbor, then \(N[u] \subseteq N[v]\). Denoting by s(G) the number of simplicial vertices of G Lemma 3.1 thus implies:

Corollary 3.3

If G is a graph, then \({{\,\mathrm{\mathrm sg_e}\,}}(G) \ge s(G)\).

Since in \(K_n\) every vertex is simplicial, Corollary 3.3 implies that \({{\,\mathrm{\mathrm sg_e}\,}}(K_n) = n\). We can also deduce this fact from Lemma 3.1 by observing that each pair of vertices of \(K_n\) are twins.

Lemma 3.1 implies also the following.

Corollary 3.4

If a graph G contains a universal vertex, then \({{\,\mathrm{\mathrm sg_e}\,}}(G) \ge n(G)-1\). Moreover, if there is only one universal vertex, then \({{\,\mathrm{\mathrm sg_e}\,}}(G) = n(G)-1\).

Proof

Let w be a universal vertex of G. Then, w is a dominant neighbor of every vertex \(u \in V(G) {\setminus } \{w\}\), and hence, Lemma 3.1 implies that \(V(G) {\setminus } \{w\} \subseteq U\) for every strong edge geodetic set U of G. Thus, \({{\,\mathrm{\mathrm sg_e}\,}}(G) \ge n(G)-1\). In the case when w is a unique universal vertex of G, then with the same arguments as we had in the last part of the proof of Proposition 3.2, we infer that \(V(G){\setminus }\{w\}\) is a strong edge geodetic set. Hence, \({{\,\mathrm{\mathrm sg_e}\,}}(G) \le n(G)-1\) when G has a unique universal vertex, so that in this case, \({{\,\mathrm{\mathrm sg_e}\,}}(G) = n(G)-1\). \(\square \)

The second assertion of Corollary 3.4 was earlier presented as [25, Theorem 5]. Moreover, in [25, Theorem 5], it was also claimed that \({{\,\mathrm{\mathrm sg_e}\,}}(P_2 \,\square \,K_m) = 2\,m - 2\). It can be checked that the result is not true and that instead the Cartesian products \(P_2 \,\square \,K_m\) also belong to the family of graphs G for which \({{\,\mathrm{\mathrm sg_e}\,}}(G) \ge n(G)-1\). More generally, we have the following result.

Theorem 3.5

If \(m \ge 3\) and \(n \ge 2\), then

$$\begin{aligned} {{\,\mathrm{\mathrm sg_e}\,}}(P_n \,\square \,K_m) = {\left\{ \begin{array}{ll} m k; &{} n =k^2, \\ m k + (m-1); &{} n = k^2 + h, 1 \le h \le k, \\ m k + m; &{} n = k^2+h, k+1 \le h \le 2k. \end{array}\right. } \end{aligned}$$

Proof

Set \(V(K_m) = [m]\) and \(V(P_n) = [n]\) where \(i(i+1) \in E(P_n)\) for \(i \in [n-1]\). If \(y\in V(K_m)\), then we will denote by \(P_n^y\) the subgraph of \(P_n\,\square \,K_m\) induced by the vertices (iy), \(i\in [n]\). \(P_n^y\) is also called a \(P_n\)-layer of \(P_n\,\square \,K_m\) and is isomorphic to \(P_n\). Throughout the proof, we will use the fact that in a shortest path of \(P_n \,\square \,K_m\), there is at most one edge between two distinct \(P_n\)-layers.

Consider first the case \(n=k^2\), where \(k \in \mathbb {N}\). In this case, we claim that \(U_1= \bigcup _{i=1}^k \bigcup _{j=1}^m \{(i^2,j)\}\) is a strong edge geodetic set of \(P_n \,\square \,K_m\). To cover all the edges of \(P_n \,\square \,K_m\), we proceed as follows. For every \(j \in [m]\), put to \(\widehat{U_1}\) the unique shortest path between the vertices (1, j) and \((k^2,j)\). For every pair \(y_1,y_2 \in V(K_m)\), \(y_1 < y_2\), we put the following shortest paths to \(\widehat{U_1}\).

  • For every \(i\in [k]\), put to \(\widehat{U_1}\) the unique shortest path (of length 1) between the vertices \((i^2,y_1)\) and \((i^2,y_2)\).

  • For every \(2\le i \le k\), and for every \(l \in [i-1]\), put to \(\widehat{U_1}\) the shortest path between the vertices \((l^2,y_1)\) and \((i^2,y_2)\) that contains the edge \(((i-1)^2+l,y_1)((i-1)^2+l,y_2)\), and the shortest path between the vertices \((l^2,y_2)\) and \((i^2,y_1)\) that passes through the edge \((i(i-1)+l,y_1)(i(i-1)+l,y_2)\). See Fig. 2 for an example, where the vertices from \(U_1\) are drawn in black.

Fig. 2
figure 2

Shortest paths for \(n=16\) and \((y_1,y_2,i,l)\in \{(m-1,m,2,1), (m-1,m,3,2), (1,2,3,1), (1,m,4,3)\}\)

The shortest paths from \(\widehat{U_1}\) cover all the edges of \(P_n \,\square \,K_m\), and hence, we can conclude that \({{\,\mathrm{\mathrm sg_e}\,}}(P_n \,\square \,K_m) \le mk\) when \(n = k^2\).

Assume next that \(n=k^2+h\), where \(h \in [k]\). Then, we claim that the set \(U_2 = U_1 \cup \bigcup _{j=2}^m \{(n,j)\}\) is a strong edge geodetic set of \(P_n \,\square \,K_m\).

  • First, put all the shortest paths from \(\widehat{U_1}\) to \(\widehat{U_2}\).

  • For every pair \(y_1,y_2 \in V(K_m)\), where \(y_1 < y_2\), and for every \(i \in [h]\), put to \(\widehat{U_2}\) the shortest path between the vertices \((i^2,y_1)\) and \((n,y_2)\) that contains the edge \((k^2+i,y_1)(k^2+i,y_2)\). See Fig. 3 for an example, where the vertices from \(U_2\) are again drawn in black.

  • For every \(y \in \{2,\ldots ,m\}\), put to \(\widehat{U_2}\) the unique shortest path between the vertices (1, y) and (ny). Note that all the edges from \(P_n^1\) are already covered by the shortest path from \(\widehat{U_2}\) between vertices \((h^2,1)\) and (n, 2).

Fig. 3
figure 3

Shortest paths for \(n=19\) and \((y_1,y_2,i) \in \{(1,2,3), (2,m-1,2), (m-1,m,1)\}\)

Since the shortest paths from \(\widehat{U_2}\) cover all the edges of \(P_n \,\square \,K_m\), we can conclude that \({{\,\mathrm{\mathrm sg_e}\,}}(P_n \,\square \,K_m) \le mk + (m-1)\), when \(n = k^2+h\) and \(h \in [k]\).

Assume finally that \(n=k^2+h\), where \(k+1 \le h \le 2k\). In this case, we claim that \(U_3 = U_1 \cup \bigcup _{j=1}^m \{(n,j)\}\) is a strong edge geodetic set of \(P_n \,\square \,K_m\) and proceed as follows.

  • Put all the shortest paths from \(\widehat{U_1}\) to \(\widehat{U_3}\).

  • For every pair \(y_1,y_2 \in V(K_m)\), where \(y_1 < y_2\), do the following. For every \(i \in [k]\), put to \(\widehat{U_3}\) the shortest path between vertices \((i^2,y_1)\) and \((n,y_2)\) that contains the edge \((k^2+i,y_1)(k^2+i,y_2)\). Moreover, for every \(i \in [h-k]\), also add the shortest path between the vertices \((n,y_1)\) and \((i^2,y_2)\) that contains the edge \((k(k+1)+i,y_1)(k(k+1)+i,y_2)\). In Fig. 4, examples are drawn with the vertices from \(U_3\) again in black.

  • For every \(j \in [m]\), put to \(\widehat{U_3}\) the unique shortest path between the vertices (1, j) and (nj).

Fig. 4
figure 4

Shortest paths for \(n=22\) and \((y_1,y_2,i) \in \{(1,2,3), (m-1,m,2)\}\)

Since the shortest paths from \(\widehat{U_3}\) cover all the edges of \(P_n \,\square \,K_m\), we get the upper bound \({{\,\mathrm{\mathrm sg_e}\,}}(P_n \,\square \,K_m) \le mk + m\) when \(n = k^2+h\) with \(k+1 \le h \le 2k\).

In the second part of the proof, we need to demonstrate that the obtained upper bounds are sharp, that is, there exist no smaller strong edge geodetic sets as the one constructed above. Let U be a arbitrary strong edge geodetic set of \(P_n \,\square \,K_m\).

Assume first that \(n = k^2\) for some \(k \in \mathbb {N}\). Then, we need to show that \(|U| \ge m k\). If for every vertex \(y \in K_m\), the set U has at least k vertices in the \(P_n^y\)-layer, then clearly \(|U|\ge mk\). Assume, therefore, that for some \(y_i \in V(K_m)\), the \(P_n^{y_i}\)- layer contains \(k-l\), \(l \ge 1\), vertices from U. Since \(|V(P_n^{y_i}) \cap U| = k-l\), for every vertex \(y \in V(K_m)\), \(y\ne y_i\), the strong edge geodetic set U has to have at least x vertices from \(P_n^{y}\), where \((k-l) x \ge k^2\), to cover all the edges between \(P_n^{y_i}\) and \(P_n^y\). Because \(x \ge k^2/(k-l) = k + kl/(k-l) \ge k + kl/k = k+l\), we get

$$\begin{aligned} |U| \ge k-l+(m-1)(k+l) = mk + (m-2)l \ge mk+1, \end{aligned}$$

where the last assertion follows, since \(m \ge 3\) and \(l \ge 1\). We conclude that in any case, \(|U| \ge mk\).

Assume second that \(n = k^2 + h\), where \(1 \le h \le k\). Now, we need to prove that \({{\,\mathrm{\mathrm sg_e}\,}}(P_n \,\square \,K_m) \ge m(k+1)-1\). If, for every vertex \(y \in K_m\), the set U has at least \(k+1\) vertices in \(P_n^y\), then clearly \(|U| \ge m(k+1)\) and we are done. Assume therefore that for some \(y_i \in V(K_m)\), the set U has \((k+1)-l\), \(l \ge 1\), vertices from \(P_n^{y_i}\). Since \(|V(P_n^{y_i}) \cap U| \le k+1-l\), for every vertex \(y \in V(K_m)\), \(y\ne y_i\), the set U has to have at least x vertices from \(P_n^{y}\), where \((k+1-l)x \ge k^2+h\) has to hold to cover all the edges between \(P_n^{y_i}\) and \(P_n^y\). Because x is an integer, we can compute as follows:

$$\begin{aligned} x&\ge \bigg \lceil \frac{k^2+h}{k+1-l} \bigg \rceil = \bigg \lceil \frac{k (k+h/k)}{k+1-l} \bigg \rceil = \bigg \lceil \frac{k (k+1-l) + k(h/k-1+l)}{k+1-l} \bigg \rceil \\&= k + \bigg \lceil \frac{k(h/k-1+l)}{k+1-l} \bigg \rceil \,. \end{aligned}$$

Because \(l \ge 1\) and therefore \(1/(k+1-\ell ) \ge 1/k\), we also have

$$\begin{aligned} x \ge k + \bigg \lceil \frac{k(h/k-1+l)}{k} \bigg \rceil = k + l-1+\bigg \lceil \frac{h}{k} \bigg \rceil . \end{aligned}$$

Since \(h\in [k]\), we have \(\big \lceil h/k \big \rceil = 1\) and therefore \(x \ge k+l\). Altogether

$$\begin{aligned} |U|&\ge k+1-l+(m-1)(k+l) = mk+(m-2)l+1 \\&\ge mk+(m-2)+1 = m(k+1)-1 \end{aligned}$$

which we wanted to show.

The remaining case is when \(n = k^2 + h\), where \(k+1 \le h \le 2k\). Now, we need to prove that \({{\,\mathrm{\mathrm sg_e}\,}}(P_n \,\square \,K_m) \ge m(k+1)\). If for every vertex \(y \in K_m\), the set U has at least \(k+1\) vertices from \(P_n^y\), then clearly \(|U|\ge m(k+1)\). Assume therefore that for some \(y_i \in V(K_m)\), the set U has \((k+1)-l\), \(l \ge 1\), vertices from \(P_n^{y_i}\). Therefore, \(|V(P_n^{y_i}) \cap U| \le k+1-l\), and hence, for every vertex \(y \in V(K_m)\), \(y\ne y_i\), the set U has to have at least x vertices from \(P_n^{y}\), where \((k+1-l)x \ge k^2+h\) has to hold to cover all the edges between \(P_n^{y_i}\) and \(P_n^y\). Because x is an integer and \(l \ge 1\), we can similarly as in the previous case estimate that

$$\begin{aligned} x \ge k + l-1+\big \lceil h/k \big \rceil . \end{aligned}$$

Because h is an integer between \(k+1\) and 2k, we have \(\big \lceil h/k \big \rceil = 2\), and therefore, \(x \ge k + l + 1\). Altogether, we see that

$$\begin{aligned} |U|&\ge k+1-l+(m-1)(k+l+1)=m(k+1)+(m-2)l \\&\ge m(k+1)+1\,, \end{aligned}$$

where the last assertion holds, since \(m \ge 3\) and \(l \ge 1\). \(\square \)

The following special case of Theorem 3.5 has been reported earlier in [25, Theorem 14].

Corollary 3.6

If \(k\ge 2\) and \(m\ge 3\), then \({{\,\mathrm{\mathrm sg_e}\,}}(P_{k^2} \,\square \,K_m) = mk\).