1 Introduction

The metric dimension of a connected graph is a well-known parameter introduced in the seventies [7, 13]. Since then, it has been extensively studied from many different points of view, such as variations of the original definition, computational aspects and practical applications [10]. Two recent surveys about this topic [11, 14] provide an extensive review of the research developed around it.

All the graphs considered in this paper are finite, simple and connected. We quote the definition of the metric dimension from [1], which emphasizes the role of the coordinates.

Definition 1

([1, 7, 13]) The metric representation of a vertex \(u\in V(G)\) with respect to a vertex subset \(W=\{\omega _1, \dots , \omega _n\}\subset V(G)\) is \(r(u\vert W)=(d(u,\omega _1), \dots d(u,\omega _n))\). A vertex subset W of a graph G is a resolving set if \(r(u\vert W)\ne r(v\vert W)\), for each pair of vertices \(u,v\in V(G)\), with \(u\ne v\). The metric dimension of G, denoted by \(\dim (G)\), is the minimum cardinality of a resolving set of G. A metric basis of G is a resolving set of cardinality \(\dim (G)\).

Hence, given a graph G and a resolving set W with n vertices, a finite set of metric representation vectors \(S=\{ r(u\vert W):u\in V(G)\}\subset {\mathbb {Z}}^n\) is provided. Some results related to properties shared by the graphs representing the same vector set can be found in [3, 4]. In this paper, we address the problem from a different point of view and we focus on the following questions. Given a finite subset \(S\subset {\mathbb {Z}}^n\), is there a graph G such that S is the set of metric representation vectors for some resolving set W? If the answer is positive, is such graph unique? Moreover, we want to give the answers to both questions just by means of elementary properties of the elements of S.

The following examples show that if \(S\subset {\mathbb {Z}}^n\) is a set of metric representation vectors for some graph G and some resolving set W, neither the resolving set W nor the graph G, are necessarily unique. Moreover, there exist resolving sets of non-isomorphic graphs that give rise to the same metric representation set.

Example 1

The subset \(S=\{(0,1), (0,2), (1,1)\}\) of \({\mathbb {Z}}^2\) is not a set of metric representation vectors of any graph. Suppose on the contrary that there exists a graph G and a resolving set \(W=\{\omega _1, \omega _2\}\) such that \(S=\{r(u\vert W):u\in V(G)\}\). Then, there exist \(u,v\in V(G)\) satisfying \((0,1)=(d(u,\omega _1), d(u,\omega _2))\) and \((0,2)=(d(v,\omega _1),d(v,\omega _2))\). This means that \(u=v=\omega _1\), but \(d(\omega _1,\omega _2)=d(u,\omega _2)=1\ne 2=d(v,\omega _2)=d(\omega _1,\omega _2)\), a contradiction.

Example 2

Consider the set \(S=\{ (0,1,1,1), (1,0,1,1), (1,1,0,1),(1,1,1,0), (1,1,1,1)\}\) of \({\mathbb {Z}}^4\). Clearly, any subset W with four vertices of a complete graph of order 5 satisfies \(S=\{r(u\vert W):u\in V(K_5)\}\). Therefore, S is the set of metric representation vectors of several resolving sets of the same graph.

Example 3

Let \(S=\{ (0,2), (2,0), (1,1), (3,1), (1,3)\}\subset {\mathbb {Z}}^2\) and consider the path \(P_5\) depicted in Fig. 1. Then, \(W=\{u_2,u_4\}\) is a resolving set of \(P_5\) and \(S=\{r(u\vert W):u\in V(P_5)\}\). Moreover, it can be easily checked that W is the only resolving set of \(P_5\) with this metric representation vector set.

Fig. 1
figure 1

A resolving set of the path \(P_5\)

Example 4

In Fig. 2, two non-isomorphic graphs \(G_1\) and \(G_2\) are shown. In both cases, the set \(W=\{\omega _1, \omega _2, \omega _3\}\) (black vertices) is a resolving set. Moreover, \(\{r(u\vert W):u\in V(G_1)\} =\{r(v\vert W):v\in V(G_2)\}=\{(0,1,2), (1,0,1), (2,1,0), (1,2,3), (2,3,2), (3,2,1), (2,1,2), (1,2,1)\}\). Therefore, two non-isomorphic graphs can share the same metric representation vector set for some resolving sets.

Fig. 2
figure 2

Two non-isomorphic graphs sharing the same metric representation vector set

The paper is organized as follows. In Sect. 2, we introduce the concept of set realizable as the metric representation vectors of a graph and we characterize such sets by means of their internal features. In Sect. 3, we study the problem of the uniqueness of the realization, introducing the notion of equivalent realizations. To this end, we first explore in depth the relationship between realizable sets and the strong product of paths. Finally, we present necessary and sufficient conditions to ensure the uniqueness of realizations for subsets of \({\mathbb {Z}}^2\).

From now on, [n] denotes the set \(\{1,2,\dots , n\}\), for every integer \(n\ge 1\). Also, if \(x\in {\mathbb {Z}}^n\), then \(x_i\) denotes its i-th coordinate, that is, \(x=(x_1,\dots ,x_n)\).

2 Realizable Sets

In this section, we present some basic properties of the vector sets that are realizable as the metric representation vector set of a graph. Moreover, we characterize such vector sets in terms of some of those properties. First of all, we pose the following definition.

Definition 2

A subset \(S\subset {\mathbb {Z}}^n\) is realizable if there exist a graph G and a resolving set W of G such that \(S=\{r(u\vert W):u\in V(G)\}\). In such a case, we say that (GW) is a realization of S.

From now on, if (GW) is a realization of S, then for each \(x\in S\), we denote by \(u_G(x)\) the only vertex in G such that its metric representation with respect to W is x, so that \(r(u_G(x)\vert W)=x\). We write simply u(x) if the graph G is clear from context.

The following properties can be easily derived from the definition.

Proposition 1

Let (GW) be a realization of a set \(S\subset {\mathbb {Z}}^n\). Then:

  1. 1.

    \(\vert V(G)\vert =\vert S\vert \).

  2. 2.

    \(\vert W\vert =n\) and therefore, \(\dim (G)\le n\le \vert S\vert \).

  3. 3.

    If \(x\in S\), then \(x_i\ge 0\), for every \(i\in [n]\). Moreover, x has at most one coordinate equal to zero.

  4. 4.

    For every \(i\in [n]\), there exists a unique \(x\in S\) such that \(x_i=0\).

Proof

  1. 1.

    We have \(\vert V(G)\vert =\vert \{r(u\vert W):u\in V(G)\}\vert =\vert S\vert \), since W is a resolving set of G.

  2. 2.

    If \(v\in V(G)\), then \(r(v\vert W)\in S\subset {\mathbb {Z}}^n\). Hence, \(r(u\vert W)\) is a vector with n coordinates and \(\vert W\vert =n\). Therefore, \(\dim (G)\le \vert W\vert =n\le \vert V(G)\vert =\vert S\vert \).

  3. 3.

    Suppose that \(W=\{\omega _1,\dots , \omega _n\}\). Then, \(x_i=d(u(x),\omega _i)\ge 0\), for every \(x\in S\) and for every \(i\in [n]\). Moreover, if \(x\in S\) satisfies \(x_i=x_j=0\), then \(u(x)=\omega _i=\omega _j\), that implies \(i=j\). Therefore, x has at most one coordinate equal to zero.

  4. 4.

    Let \(i\in [n]\) and take \(x=r(\omega _i \vert W)\). Clearly, \(x\in S\) and \(x_i=d(\omega _i,\omega _i)=0\). Moreover, if \(y\in S\) satisfies \(y_i=0\), then \(u(y)=\omega _i\), because \(y_i=d(u(y),\omega _i)=0\). Therefore, \(x=y=r(\omega _i\vert W)\), as desired.

\(\square \)

Remark 1

For every graph G and every resolving set W of G, it is obvious from the definition that (GW) is a realization of the set of distance vectors \(\{ r(u\vert W):u\in V(G)\}\subset {\mathbb {Z}}^{\vert W\vert }\).

Corollary 1

Let G be a graph and n an integer such that \(n\le \vert V(G) \vert \). Then, \(\dim (G)\le n\) if and only if there is a resolving set W of G such that (GW) is a realization of a set \(S\subset {\mathbb {Z}}^n\).

Proof

If (GW) is a realization of \(S\subset {\mathbb {Z}}^n\), by Proposition 1 we know that \(\dim (G)\le n\). Conversely, if \(\dim (G)\le n\), then there exists a metric basis M such that \(\vert M\vert =\dim (G)\). Let \(W\subset V(G)\) be such that \(M\subset W\) and \(\vert W\vert =n\). Clearly, W is a resolving set of G and, by Remark 1, (GW) is a realization of \(S=\{r(u\vert W):u\in V(G)\}\subset {\mathbb {Z}}^{\vert W\vert }={\mathbb {Z}}^n\). \(\square \)

We now present the main result of this section, that is, the characterization of realizable subsets of \({\mathbb {Z}}^n\).

Theorem 1

A subset \(S\subset {\mathbb {Z}}^n\) is realizable if and only if the following properties hold.

  1. 1.

    If \(x\in S\), then \(x_i\ge 0\) for every \(i\in [n]\). Moreover, x has at most one coordinate equal to zero.

  2. 2.

    For every \(i\in [n]\), there exists exactly one element \(x\in S\) such that \(x_i=0\).

  3. 3.

    If \(x\in S\) and \(x_i > 0\), for any \(i\in [n]\), then there exists \(y\in S\) satisfying \(y_i=x_i-1\) and \(\max _{j\in [n]} \{\vert y_j-x_j \vert \}\le 1\).

Proof

Suppose first that the graph (GW) is a realization of S, where \(W=\{ \omega _1, \dots , \omega _n\}\). Notice that properties 1 and 2 have been proven in Proposition 1. To prove property 3, let \(x\in S\) be such that \(x_i>0\). Then, \(d(u(x),\omega _i)=x_i>0\). Let v be the neighbor of u(x) in a shortest path from u(x) to \(\omega _i\), and let \(y=r(v\vert W)\). Then, \(y=r(v\vert W)\in S\), \(y_i=d(v,\omega _i)=x_i-1\) and \(\vert y_j-x_j\vert =\vert d(v,\omega _j)-d(u(x),\omega _j)\vert \le 1\), for every \(j\in [n]\), because u(x) and v are neighbors in G. Hence, \(\max _{j\in [n]} \{\vert y_j-x_j \vert \}\le 1\).

Conversely, let \(S\subset {\mathbb {Z}}^n\) be a subset satisfying properties 1, 2 and 3. We define a graph \(G=(V,E)\) as follows: \(V=S\) and, for \(x,y\in S\), \(xy\in E\) if and only if \(\max _{j\in [n]} \{\vert y_j-x_j\vert \}=1\).

Then, the set \(W=\{x\in S:x_i=0, { \mathrm \ for\ some\ } i\in [n]\}\) clearly satisfies \(\vert W \vert =n\), by properties 1 and 2. We denote by \(\omega _i\) the only vertex of W with i-th coordinate equal to 0.

Let us see that (GW) is a realization of S. To this end, it is enough to prove that \(r(x\vert W)=x\) for every \(x\in S\) or, equivalently, \(d(x,\omega _i)=x_i\), for every \(x\in S\) and \(i\in [n]\). Let \(x\in S\), and let \(i\in [n]\). If \(x_i=0\), then \(x=\omega _i\) and \(d(x,\omega _i)=d(\omega _i,\omega _i)=0=x _i\).

Now, assume that \(x_i>0\). Let \(\omega _i=v_0,v_1,\dots , v_{k}=x\) be a shortest path between \(\omega _i\) and x. Let us see first that \(d(x,\omega _i)\ge x_i\). The i-th coordinates of two consecutive vertices of G differ in at most one unit, by definition of the edges of G. Therefore, \(d(x,\omega _i)=k\ge x_i\) because the i-th coordinate of \(\omega _i\) is zero and the i-th coordinate of x is \(x_i\).

Now, we prove that \(d(x,\omega _i)\le x_i\). By property 3, there exists \(y^1\in S\) such that \(y^1_i=x_i-1\) and \(\max _{j\in [n]} \{\vert y^{1}_{j}-x_j\vert \}\le 1\). Therefore, \(\max _{j\in [n]} \{\vert y^1_j-x_j \vert \}=\vert y^1_i-x_i\vert =1\) and, consequently, \(x,y^1\) are neighbors in G. If \(y^1_i=x_i-1>0\), by using the same argument as before, there exists \(y^2\in S\) such that \(y^2_i=y^1_i-1=x_i-2\), \(\max _{j\in [n]} \{\vert y^2_j-y^1_j\vert \}=\vert y^2_i-y^1_i\vert =1\) and \(y^2,y^1\) are neighbors in G. By repeatedly applying the same argument, we obtain a vertex sequence \(x=y^0, y^1, y^2, \dots ,y^{x_i}\) such that \(y^j_i=x_i-j\) and \(y^j, y^{j+1}\) are neighbors in G, if \(0\le j< x_i\). In particular, \(y^{x_i}_i=x_i-x_i=0\) and therefore \(y^{x_i}=\omega _i\). Finally, since \(y^0, y^1, y^2, \dots ,y^{x_i}\) defines a path of length \(x_i\) from x to \(\omega _i\), we deduce \(d(x,\omega _i)\le x_i\). \(\square \)

Conditions 1 and 2 in the theorem above are basic properties related to the fact that the coordinates of the metric representation vectors are distances. The meaning of the third condition is also clear, since it allows us to ensure that each vertex at a positive distance, say d, from a vertex w of the resolving set, has at least a neighbor at distance \(d-1\) from w.

3 Uniqueness

Once we have characterized the sets of \({\mathbb {Z}}^n\) that are realizable as the metric representation vector set of a graph, our purpose is now to study the uniqueness of its realizations. In order to put this problem in context, we first show some examples.

Example 5

It is straightforward to check that the set \(S=\{ (0,3),(3,0), (1,2),\) \( (2,1), (1,4), (4,1), (2,5), (5,2), (3,4), (4,3)\}\) is realizable by \((C_{10},W)\) and by \((C_{10}, W')\), if \(V(C_{10})=\{ u_i:1\le i\le 10 \}\), \(E(C_{10})=\{u_iu_{i+1}:1\le i< 10\}\cup \{ u_{10} u_1\}\), and \(W=\{u_1, u_8\}\), \(W'=\{u_3, u_6\}\) (see Fig. 3).

Fig. 3
figure 3

\((C_{10},\{u_1,u_8\})\) (left) and \((C_{10},\{u_3,u_6\})\) (right) are realizations of the set \(S=\{ (0,3), (3,0), (1,2), (2,1), (1,4), (4,1), \) \((2,5), (5,2), (3,4), (4,3)\}\)

Example 6

In Fig. 4a, (GW), where \(W=\{\omega _1, \omega _2\}\), is a realization of the set \(S=\{ (0,3),(3,0), (1,2),(2,1), (2,3), (3,2), (1,4), (4,1), (2,5), (5,2),(3,4), (4,3), (4,5) , (5,4)\}\). Notice that \(r(a\vert W)=(2,3)\) and \(r(b\vert W)=(3,2)\). In Fig. 4b, \((G, W')\) is a realization of S, where \(W'=\{z_1, z_2\}\) and, in this case, \(r(x\vert W')=(2,3)\) and \(r(y\vert W')=(3,2)\).

Fig. 4
figure 4

a \((G,\{w_1,w_2\})\) and b \((G,\{z_1,z_2\})\) are realizations of the set \(S=\{ (0,3),(3,0), (1,2), (2,1),(2,3), (3,2), (1,4), (4,1), (2,5), (5,2), (3,4), (4,3), (4,5) , (5,4)\}\). The vertices corresponding to the vectors (2, 3) and (3, 2) are a and b (a), and x and y (b)

Taking a look to both examples, we notice that the realizations given in Example 5 are essentially equal, but this is not the case in Example 6, because the vertices corresponding to the vectors (2, 3) and (3, 2) are neighbors if we consider the realization (GW), but they are not when we consider the realization \((G,W')\).

These examples lead us to the following definition.

Definition 3

Let (GW) and \((G',W')\) be two realizations of a set \(S\subset {\mathbb {Z}}^n\). We say that both realizations are equivalent if the map \(f:V(G)\rightarrow V(G')\) such that \(r(u\vert W)=r(f(u)\vert W')\) is a graph isomorphism.

With this definition, the realizations given in Example 5 are equivalent, but not those given in Example 6.

Notice that two equivalent realizations of \(S\subset {\mathbb {Z}}^n\) necessarily involve isomorphic graphs. However, the converse is not true, as shown in Example 6 (see Fig. 4), where two non-equivalent realizations of a set S are given, both sharing the same graph.

Definition 3 provides a suitable framework to study the problem of the uniqueness of the realization of a set of vectors.

Definition 4

A finite subset \(S\subset {\mathbb {Z}}^n\) is uniquely realizable if all of the realizations of S are equivalent.

Remark 2

Observe that the definition of equivalent realizations establishes an equivalence relation in the set of all realizations of a fixed set \(S\subseteq {\mathbb {Z}}^n\). With this terminology, the uniqueness of the realizations consists of characterizing all sets S such that there is only one equivalence class.

In order to address the problem of the uniqueness of the realization, notice that for every realizable set of vectors S, it is possible to build a graph G and a resolving set W realizing S with the procedure described in the proof of Theorem 1. For this reason, we propose the following definition.

Definition 5

Let \(S\subset {\mathbb {Z}}^n\) be a realizable set. The canonical realization of S is \((\widehat{G},\widehat{W})\), where

$$\begin{aligned} V(\widehat{G})=S, \ \ E(\widehat{G})=\{ xy:x,y\in S \text { and } \max _{i\in [n]} \{\vert y_i-x_i\vert \}=1\}, \end{aligned}$$

and

$$\begin{aligned} \widehat{W}=\{x\in S:x_i=0, \mathrm{\ for\ some\ } i\in [n]\}. \end{aligned}$$

Remark 3

Since the canonical realization exists for every realizable set, a set S of vectors is uniquely realizable if and only if all the realizations of S are equivalent to the canonical one.

Thus, we now focus on studying the structure of the canonical realization that can be viewed as a subgraph of the strong product of paths.

The strong product of graphs was introduced in [12], and extensive information on this concept can be found in [8]. The strong product of two graphs G and H, denoted by \(G\boxtimes H\), is the graph such that \(V(G\boxtimes H)=V(G)\times V(H)\) and two vertices \((g,h), (g',h')\in V(G)\times V(H)\) are adjacent in \(G\boxtimes H\) if and only if one of the following conditions holds:

  • \(g=g'\) and \(h,h'\) are adjacent in H,

  • \(h=h'\) and \(g,g'\) are adjacent in G,

  • \(g,g'\) are adjacent in G and \(h,h'\) are adjacent in H.

The distance between two vertices in \(G\boxtimes H\) is given by

$$\begin{aligned} d((g,h), (g',h'))=\max \{d_G(g,g'), d_H(h,h')\}. \end{aligned}$$

The natural extension of this operation to a finite family of graphs \(\{G_i:i\in [n]\}\) provides the graph \(G_1\boxtimes \dots \boxtimes G_n\) with vertex set \(V(G_1)\times \dots \times V(G_n)\) and such that two vertices \((g_1,\dots ,g_n)\) and \((g_1',\dots ,g_n')\) from \( V(G_1)\times \dots \times V(G_n)\) are adjacent if and only if \(\max _{i\in [n]}\{ d_{G_i}( g_i,g'_i) \}=1\).

Let \(P_r\) denote the path graph of order r with vertex set \(V(P_r)=\{0,1,\dots , r-1\}\), where \(i-1\) and i are adjacent for every \(i\in [r-1]\). Therefore, \(d_{P_r}(i,j)=\vert i-j\vert \) for any two vertices ij in \(P_r\). Following this notation, the strong product of n copies of \(P_r\) is the graph \(P_r \boxtimes {\mathop {\dots }\limits ^{n)}} \boxtimes P_r\), with vertex set \(\{0,1,\dots , r-1\}^n\) and two vertices xy are adjacent if and only if \(\max _{i\in [n]}\{ \vert x_i-y_i\vert \}=1\).

In addition, the graph \(\widehat{G}\) described in Definition 5 is clearly the subgraph induced by S in the strong product of n paths of order at least \(1+\max \{x_i:x\in S, i\in [n]\}\). We next prove that every graph G of a realization of a subset S of \({\mathbb {Z}}^n\) is isomorphic to a subgraph of the strong product of n paths, not necessarily induced.

Proposition 2

Let (GW) be a realization of a set \(S\subset {\mathbb {Z}}^n\). The map \(\phi :V(G)\rightarrow S\) such that \(\phi (v)=r(v\vert W)\) defines a graph isomorphism between G and a subgraph of the strong product of n paths of order r, for any \(r\ge 1+\max \{x_i:x\in S, i\in [n]\}\).

Proof

The choice of r and Condition 1 of Theorem 1 ensure that the map is well defined. Moreover, \(\phi \) is injective, because W is a resolving set, and \(\phi (V)=S\), because (GW) is a realization of S. Hence, \(\phi \) is a bijection.

Now, we prove that \(\phi (v)\phi (v')\in E(P_r \boxtimes {\mathop {\dots }\limits ^{n)}} \boxtimes P_r)\), if \(vv'\in E(G)\). Indeed, recall that \(v=u(x)\) and \(v'=u(y)\) for some \(x,y\in S\), such that \(\phi (v)=r(v\vert W)=x\) and \(\phi (v')=r(v'\vert W)=y\). Hence, \(\vert y_i-x_i\vert =\vert d(u(y),\omega _i)-d(u(x),\omega _i)\vert =\vert d(v',\omega _i)-d(v,\omega _i)\vert \le 1\), for every \(i\in [n]\), because v and \(v'\) are neighbors in G. Therefore, \(\max _{i\in [n]}\{ \vert y_i-x_i\vert \}\le 1\). Moreover, \(x=r(v\vert W)\ne r(v'\vert W)=y\), because \(v\ne v'\). Thus, there exists \(j\in [n]\) such that \(x_j\ne y_j\), implying that \(\max _{i\in [n]}\{ \vert y_i-x_i\vert \}=1\). This means that \(xy\in E(P_r \boxtimes {\mathop {\dots }\limits ^{n)}} \boxtimes P_r)\), where \(x=\phi (v)\) and \(y=\phi (v')\). Hence, G is isomorphic to the graph \(G(S,\{\phi (v)\phi (v' ) : vv'\in E(G)\})\), that is, a subgraph of the strong product of n paths of order at least \(1+\max \{x_i:x\in S, i\in [n]\}\). \(\square \)

A first consequence of this construction is that we can provide a generalization to every dimension of the property suggested in [10] and shown in [2], stating that every graph with metric dimension at most two can be represented as a subgraph of the strong product of two paths. Notice that this subgraph is non-necessarily induced.

Corollary 2

Let G be a graph with \(\dim (G)\le n\), and let r be an integer such that \(r\ge 1+diam(G)\). Then, G is isomorphic to a subgraph of \(P_r \boxtimes {\mathop {\dots }\limits ^{n)}} \boxtimes P_r\), not necessarily induced.

It was proved in [6] that any graph can be canonically isometrically embedded into the Cartesian product of graphs. Following this idea, the isometric dimension of a graph G is the least number of graphs needed to isometrically embed G into a Cartesian product. Moreover, the strong isometric dimension of a graph [5, 9] is the least number k such that G embeds isometrically into the strong product of k paths. A general reference about isometric embeddings of graphs into product graphs can be found in [8].

Corollary 2 has a similar flavor but regarding the metric dimension. However, notice that the isomorphism we are using is not an isometric embedding, because it just preserves the distances from the vertices in the resolving set to any other vertex of the graph, but not necessarily between every pair of vertices.

The map \(\phi \) defined in Proposition 2 provides a useful tool to decide whether two realizations of a set of \({\mathbb {Z}}^n\) are equivalent, since all realizations of S can be seen as subgraphs of a common graph. Moreover, since the subgraphs of the strong product of paths associated with the realizations of a fixed S share the same vertex set, the equivalency between two realizations can be characterized by means of the edge sets. We will use the subgraph of the strong product of graphs considered in Proposition 2 to explore in depth such relationship.

Definition 6

Let (GW) be a realization of \(S\subset {\mathbb {Z}}^n\). We denote by \(G^*_W\) the subgraph of the strong product of n paths of order r, with \(r\ge 1+diam(G)\), whose vertex set is \(V(G^*_W)=S\) and whose edge set is \(E(G^*_W)=\{ xy : x=r(v\vert W), y=r(v'\vert W),vv'\in E(G)\}\).

We illustrate this definition with some examples.

Example 7

In Fig. 5a, we show the cycle with ten vertices \(C_{10}\) and its resolving set W, the set of black vertices. Note that \((C_{10},W)\) is a realization of \(S=\{ (0,3),(3,0), (1,2),(2,1), (1,4), (4,1), (2,5), (5,2), (3,4), (4,3)\}\). The subgraph \(G^*_W\) of \(P_8\boxtimes P_8\) defined above is shown in Fig. 5b.

Fig. 5
figure 5

a A realization (GW) of the set \(S=\{ (0,3),(3,0), (1,2), (2,1), (1,4), (4,1), (2,5), (5,2), (3,4), (4,3)\}\) and b the graph \(G_W^*\)

Example 8

In Fig. 6a, we show a graph G and its resolving set W, the set of black vertices. Note that (GW) is a realization of \(S=\{ (0,3),(3,0), \) (1, 2), (2, 1), (2, 3), (3, 2), (1, 4), (4, 1), (2, 5), (5, 2), (3, 4), (4, 3), (4, 5),  \( (5,4)\}\). The subgraph \(G^*_W\) of \(P_6\boxtimes P_6\) defined above is shown in Fig. 6b.

Fig. 6
figure 6

a A realization (GW) of the set \(S=\{ (0,3),(3,0), (1,2), (2,1), (2,3), (3,2), (1,4), (4,1), (2,5), (5,2), (3,4), (4,3), (4,5) , (5,4)\}\) and b the graph \(G_W^*\)

Observe that in the graph \(G^*_W\), the distance from the vertex \(w_i\in W\) to any other vertex \(x\in S\) is precisely the i-th coordinate of x, \(x_i\). Moreover, the i-th coordinates of the vertices of any shortest path from \(w_i\) to x are \(0,1,2,\dots , x_i\), respectively.

Notice also that as we have already pointed out, the subgraph \(G^*_W\) is not necessarily an induced subgraph of the strong product of paths. Moreover, by definition, \(G^*_W\) preserves the distances from a vertex in W to any other vertex, but not necessarily between two any vertices of \(G^*_W\), even if it is an induced subgraph. For instance, in Example 7 (see Fig. 5), \(G^*_W\) is an induced subgraph of the strong product of paths; however, the vertices \(u_2\) and \(u_7\) are at distance 5 in G, but the corresponding vertices in the strong product of paths (1, 4) and (4, 1) are at distance 3.

The following result is a direct consequence of Proposition 2.

Corollary 3

Let (GW) be a realization of \(S\subset {\mathbb {Z}}^n\). Then, \((G^*_W,\phi (W))\) is a realization of S equivalent to (GW).

Corollary 4

Let (GW) and \((G',W')\) be two realizations of a set \(S\subset {\mathbb {Z}}^n\). Then, (GW) and \((G',W')\) are equivalent if and only if \(E(G^*_W)=E(G'^*_{W'})\).

Proof

Assume that G and \(G'\) are equivalent realizations of S and denote by \(f:V(G)\rightarrow V(G')\) the map such that \(r(u\vert W)=r(f(u)\vert W')\), that is, a graph isomorphism, by hypothesis. Therefore, \(x=r(u(x)\vert W)=r(f(u(x))\vert W')\). We know that \(V(G^*_W)=V(G'^*_{W'})=S\), and we have to prove that \(E(G^*_W)=E(G'^*_{W'})\). Let \(x,y\in S\) then, \(xy\in E(G^*_W)\) if and only if \(u(x)u(y)\in E(G)\) if and only if \(f(u(x))f(u(y))\in E(G')\) if and only if \(xy\in E(G'^*_{W'})\).

Conversely, if \(E(G^*_W)=E(G'^*_{W'})\), then both subgraphs of \(P_r \boxtimes {\mathop {\dots }\limits ^{n)}} \boxtimes P_r\) are equal. Finally, both G and \(G'\) are equivalent to the same subgraph of \(P_r \boxtimes {\mathop {\dots }\limits ^{n)}} \boxtimes P_r\), so we obtain that G and \(G'\) are equivalent realizations of S. \(\square \)

Corollary 5

A set S is uniquely realizable if and only if \(E(G_W^*)=E(\widehat{G})\) for every realization (GW) of S.

In the following example, we show the subgraphs of the strong product equivalent to three realizations of the same set S, including the canonical one.

Example 9

We show three subgraphs of \(P_6\boxtimes P_6\) realizing the set \(S=\{ (0,3),(3,0), \) \( (1,2), (2,1), (2,3), (3,2), (1,4),(4,1), (2,5), (5,2),(3,4), (4,3), (4,5), (5,4)\}\). In each case, subgraph edges are the black ones, the vertex set are the black and the white vertices and the black vertices are the resolving set. The vertex set is S in all cases.

In Fig. 7a, b, we show the realizations given in Fig. 4a, b, respectively, and as subgraphs of \(P_6\boxtimes P_6\). We can easily check that these subgraphs of \(P_6\boxtimes P_6\) have different edge sets, so they are non-equivalent realizations of the set S. Moreover, none of them is an induced subgraph that means that they are not the canonical realization of S. Finally, the canonical realization of S is the induced subgraph of \(P_6\boxtimes P_6\) shown in Fig. 7c.

Fig. 7
figure 7

Three non-equivalent realizations of a set S as subgraphs of \(P_6\boxtimes P_6\)

It is clear that not every subgraph of \(P_r \boxtimes {\mathop {\dots }\limits ^{n)}} \boxtimes P_r\) with vertex set S is a realization of such set. However, we show in the following result that adding any available edge of the strong product to a subgraph realizing S provides a non-equivalent realization of it.

Proposition 3

Let G be a subgraph of a strong product of n paths such that (GW) is a realization of a subset \(S\subset {\mathbb {Z}}^n\) not equivalent to the canonical one. Consider a graph \(G'\) obtained by adding to G an edge of the strong product not belonging to G. Then, \((G',W)\) is a realization of S not equivalent to (GW).

Proof

Let \(x,y\in V(G)\) be such that x and y are neighbors in the strong product of paths, but not in G. Consider the graph \(G'=(V(G),E(G)\cup \{ e\})\), where \(e=xy\). Let \(z\in V(G')\). Notice that \(d_{G}(z,\omega _i)=z_i=d_{P_r \boxtimes {\mathop {\dots }\limits ^{n)}} \boxtimes P_r} (z,\omega _i)\) and therefore the addition of an edge of the strong product \(P_r \boxtimes {\mathop {\dots }\limits ^{n)}} \boxtimes P_r\) cannot decrease such distance. Thus, \(d_{G'}(z,\omega _i)=d_{G}(z,\omega _i)=z_i\). Hence, W is a resolving set of \(G'\) such that \(\{r(z\vert W):z\in V(G')\}=S\).

Finally, it is clear that G and \(G'\) have different edge sets, so by Corollary 4, (GW) and \((G',W)\) are not equivalent realizations. \(\square \)

4 Uniqueness of the Realization in the Case \(n=2\)

We now focus on the case \(n=2\), in order to characterize the vector sets which are uniquely realizable. We know that every realizable set \(S\subset {\mathbb {Z}}^2\) admits the canonical realization that is an induced subgraph of \(P_r\boxtimes P_r\). Therefore, this realization will be the only one if it is not possible to obtain another one by removing edges from it.

Contrary to what happens with the addition of edges (see Proposition 3), it is clear that removing edges from a subgraph of \(P_r \boxtimes {\mathop {\dots }\limits ^{n)}} \boxtimes P_r\) and keeping the distances between its vertices are not always possible. We focus in these ideas to characterize the uniquely realizable vector sets.

We begin by proving some technical lemmas.

Lemma 1

Let \((\widehat{G},\widehat{W})\) be the canonical realization of \(S\subset {\mathbb {Z}}^2\), with \(\widehat{W}=\{\omega _1, \omega _2\}\). Suppose that \(x\in S\) and there is a shortest path in \(\widehat{G}\) between \(\omega _1\) and x going through an edge uv. If at least one of the following conditions holds for some integers \(\alpha \) and \(\beta \):

  1. (i)

    \(u=(\alpha ,\beta +1), v=(\alpha +1,\beta ), t=(\alpha ,\beta )\in S\);

  2. (ii)

    \(u=(\alpha ,\beta +1), v=(\alpha +1,\beta +1), t=(\alpha ,\beta )\in S\);

  3. (iii)

    \(u=(\alpha ,\beta +2), v=(\alpha +1,\beta +1), t=(\alpha ,\beta )\in S\);

  4. (iv)

    \(u=(\alpha ,\beta ), v=(\alpha +1,\beta +1), t=(\alpha ,\beta +2)\in S\);

then \(\omega _1\ne u\) and there exists a shortest path between \(\omega _1\) and x avoiding the edge uv. Moreover, in such a case, the graph \(\widehat{G}-uv\) is connected.

Proof

First, in all cases \(u\ne t\) and the first coordinate of u equals the first coordinate of t, so that this coordinate cannot be zero, by property 2 of Theorem 1. This means that \(u\ne \omega _1\). Moreover, the equality of the first coordinates implies \(d(u,\omega _1)=d(t,\omega _1)\) in all cases. Notice also that t and v are neighbors in \(\widehat{G}\), by definition of \(\widehat{G}\). Therefore, we can construct a shortest path between \(\omega _1\) and x by joining a shortest path from \(w_1\) to t, the edge tv and a shortest path from v to x that clearly avoids the edge uv (see Fig. 8).

Fig. 8
figure 8

In all cases, if there is a shortest path from \(w_1\) to a vertex x that goes through uv, then there is a shortest path from \(w_1\) to x that goes through tv avoiding uv

Now, let \(x,y\in S\). We have seen that there are paths in \(\widehat{G}\) from \(w_1\) to x and to y avoiding the edge uv. Hence, it is possible to build a path in \(\widehat{G}\) between x and y avoiding the edge uv. Hence, \(\widehat{G}-uv\) is connected. \(\square \)

By interchanging the role of both coordinates in the preceding lemma, we obtain the following result.

Lemma 2

Let \((\widehat{G},\widehat{W})\) be the canonical realization of \(S\subset {\mathbb {Z}}^2\), with \(\widehat{W}=\{\omega _1, \omega _2\}\). Suppose that \(x\in S\) and there is a shortest path in \(\widehat{G}\) between \(\omega _2\) and x going through an edge uv. If one of the following conditions hold:

  1. (i)

    \(u=(\alpha +1,\beta ), v=(\alpha ,\beta +1), t=(\alpha ,\beta )\in S\);

  2. (ii)

    \(u=(\alpha +1,\beta ), v=(\alpha +1,\beta +1), t=(\alpha ,\beta )\in S\);

  3. (iii)

    \(u=(\alpha +2,\beta ), v=(\alpha +1,\beta +1), t=(\alpha ,\beta )\in S\);

  4. (iv)

    \(u=(\alpha ,\beta ), v=(\alpha +1,\beta +1), t=(\alpha +2,\beta )\in S\);

then \(\omega _2\ne u\) and there exists a shortest path between \(\omega _2\) and x avoiding the edge uv. Moreover, in such a case, the graph \(\widehat{G}-uv\) is connected.

Lemma 3

Let (GW) be a realization of \(S\subset {\mathbb {Z}}^2\), with G a subgraph of the strong product \(P_r \boxtimes P_r\). Let \(u=(u_1,u_2)\in S\). If \(u_1>0\), then at least one vertex in the set \(A=\{(u_1-1, u_2-1), (u_1-1, u_2), (u_1-1,u_2+1)\}\) belongs to S and is adjacent to u. If \(u_2>0\), then at least one vertex in \(B=\{(u_1-1, u_2-1), (u_1, u_2-1), (u_1+1,u_2-1)\}\) belongs to S and is adjacent to u (see Fig. 9).

Proof

Suppose that \(W=\{w_1,w_2\}\) and \(u=(u_1,u_2)=(d(w_1,u), d(w_2,u))\). If \(u_1>0\), then there is a neighbor of u in S at distance \(u_1-1\) from \(w_1\). Hence, at least one of the vertices of A belongs to S and is adjacent to u. Similarly, if \(u_2>0\), we derive that one of the vertices of B belongs to S and is adjacent to u. \(\square \)

Fig. 9
figure 9

At least one vertex in A and at least one vertex in B belong to S and are adjacent to u

We now prove the main result of this section that characterizes the subsets of \({\mathbb {Z}}^2\) that are uniquely realizable. They are characterized in terms of conditions of the coordinates of their elements.

Theorem 2

Let \(S\subset {\mathbb {Z}}^2\) be a realizable set. Then, there exist two non-equivalent realizations of S if an only if at least one of the following conditions holds, for some integers \(\alpha ,\beta \):

  1. 1.

    \(\{(\alpha ,\beta ),(\alpha ,\beta +1),(\alpha +1,\beta )\}\subset S\) (Fig. 10a),

  2. 2.

    \(\{(\alpha ,\beta ),(\alpha ,\beta +1),(\alpha +1,\beta +1)\}\subset S\) (Fig. 10b),

  3. 3.

    \(\{(\alpha ,\beta ),(\alpha +1,\beta ),(\alpha +1,\beta +1)\}\subset S\) (Fig. 10c),

  4. 4.

    \(\{(\alpha -1,\beta ),(\alpha ,\beta -1),(\alpha ,\beta +1),(\alpha +1,\beta )\}\subset S\) (Fig. 10d)

  5. 5.

    \(\{(\alpha ,\beta ),(\alpha ,\beta +2),(\alpha +1,\beta +1),(\alpha +2,\beta )\}\subset S\) (Fig. 10e).

Fig. 10
figure 10

The five configurations of vertices in \(S\subset {\mathbb {Z}}^2\) of Theorem 2

Proof

We first proof the necessity. Let (GW) and (HR) be two non-equivalent realizations of S. By Corollaries 3 and 4, we may assume that G and H are subgraphs of a strong product \(P_r \boxtimes P_r\) satisfying \(V(G)=V(H)=S\) and \(E(G)\ne E(H)\). Without loss of generality, we may also assume that there exist two vertices x and y in S that are neighbors in H, but not in G. In particular, these vertices are neighbors in \(P_r \boxtimes P_r\), so that their coordinates differ in at most one unit. We distinguish the following cases.

  1. 1.

    The vertices x and y have the same first coordinate. Assume that \(x=(a,b+1)\) and \(y=(a,b)\). In particular, \(b+1>0\). Since x and y are not neighbors in G, by applying Lemma 3 to x, we derive that either \(z=(a+1,b)\in S\), and then Condition 1 holds for \(\{x,y,z\}\), or \(t=(a-1,b)\in S\), and then Condition 3 holds for \(\{x,y,t\}\).

  2. 2.

    The vertices x and y have the same second coordinate. We proceed as in the preceding case but interchanging the role of the first and second coordinates, and we obtain that either Condition 1 or Condition 2 holds.

  3. 3.

    The first and second coordinates of one of the vertices are less and greater than the first and second coordinates of the other vertex, respectively. We may assume that \(x=(a,b+1)\) and \(y=(a+1,b)\). In particular, \(a+1>0\) and \(b+1>0\). If \(z=(a,b)\in S\), then \(\{x,y,z\}\) satisfies Condition 1. Otherwise, since x and y are not neighbors in G, by applying Lemma 3 to x for the set B, we obtain that \(s=(a-1,b)\in S\), and by applying Lemma 3 to y for the set A, we obtain that \(t=(a,b-1)\in S\). Thus, \(\{x,y,s,t\}\) satisfies Condition 4.

  4. 4.

    One vertex has both coordinates greater than those of the other vertex. Then, we may assume \(x=(a+1,b+1)\), \(y=(a,b)\). In particular, \(a+1>0\) and \(b+1>0\). If \(z=(a, b+1)\in S\), then \(\{x,y,z\}\) satisfies Condition 2. If \(s=(a+1, b)\in S\), then \(\{x,y,s\}\) satisfies Condition 3. Now, suppose that \(z,s\notin S\). Then, since x and y are not neighbors in G, by applying Lemma 3 to x for both sets A and B, we obtain that \(t=(a, b+2)\in S\) and \(p=(a+2, b)\in S\). Therefore, \(\{x,y,t,p\}\) satisfies Condition 5.

We now prove the sufficiency. Let \((\widehat{G},\widehat{W})\) be the canonical realization of S, with \(\widehat{W}=\{\omega _1, \omega _2\}\), that exists because S is realizable. Assume that there exist integers \(\alpha , \beta \) such that one of the conditions from 1 to 5 hold. To conclude the proof, we will see that there is an edge e of \(\widehat{G}\) such that \((\widehat{G}-e, \widehat{W})\) is also a realization of S, but not equivalent to the canonical one, because the graphs \(\widehat{G}\) and \(\widehat{G}-e\) have different size and, consequently, are not isomorphic. For this purpose, in each one of the five cases we choose an edge e of \(\widehat{G}\) such that the deletion of e does not change the distances from the vertices in W to any other vertex.

  1. 1.

    If \(\{(\alpha ,\beta ),(\alpha ,\beta +1),(\alpha +1,\beta )\}\subset S\), let \(u=(\alpha ,\beta +1)\) and \(v=(\alpha +1,\beta )\). Since \(t=(\alpha ,\beta )\in S\), if there is a shortest path in \(\widehat{G}\) between \(\omega _1\) and a vertex x going through the edge uv, then there exists a shortest path between \(\omega _1\) and x avoiding the edge uv, because Condition i) of Lemma 1 is satisfied for u, v and t. Similarly, if there is a shortest path in \(\widehat{G}\) between \(\omega _2\) and a vertex y going through the edge uv, then there exists a shortest path between \(\omega _2\) and y avoiding the edge uv, because Condition i) of Lemma 2i) is satisfied for u, v and t.

  2. 2.

    If \(\{(\alpha ,\beta ),(\alpha ,\beta +1),(\alpha +1,\beta +1)\}\subset S\), let \(u=(\alpha ,\beta +1)\) and \(v=(\alpha +1,\beta +1)\). Since \(t=(\alpha ,\beta )\in S\), if there is a shortest path in \(\widehat{G}\) from \(w_1\) to x going through uv, we derive that there is a shortest path from \(\omega _1\) to x avoiding the edge uv, because Condition ii) of Lemma 1 is satisfied for u, v and t. Notice that, in this case, there are no shortest paths between \(\omega _2\) and any other vertex y going through the edge uv, because u and v have the same second coordinate.

  3. 3.

    If \(\{(\alpha ,\beta ),(\alpha +1,\beta ),(\alpha +1,\beta +1)\}\subset S\), let \(u=(\alpha +1,\beta )\) and \(v=(\alpha +1,\beta +1)\). Since \(t=(\alpha ,\beta )\in S\), if there is a shortest path in \(\widehat{G}\) from \(w_2\) to y going through the edge uv, then we derive that there is also a shortest path from \(\omega _2\) to y avoiding the edge uv, because Condition ii) of Lemma 2 is satisfied for u, v and t. Notice that there are no shortest paths in \(\widehat{G}\) between \(\omega _1\) and any other vertex x going through the edge uv, because the first coordinates of u and v are equal.

  4. 4.

    If \(\{(\alpha -1,\beta ),(\alpha ,\beta -1),(\alpha ,\beta +1),(\alpha +1,\beta )\}\subset S\), let \(u=(\alpha ,\beta +1)\) and \(v=(\alpha +1,\beta )\). Since \((\alpha ,\beta -1)\in S\), if there is a shortest path in \(\widehat{G}\) from \(w_1\) to x going through the edge uv, then there is also a shortest path from \(w_1\) to x avoiding the edge uv, because Condition iii) of Lemma 1 is satisfied. Since \((\alpha -1,\beta )\in S\), if there is a shortest path in \(\widehat{G}\) from \(w_2\) to y going through the edge uv, then there is also a shortest path from \(w_2\) to y avoiding the edge uv, because Condition iii) of Lemma 2 is satisfied.

  5. 5.

    If \(\{(\alpha ,\beta ),(\alpha ,\beta +2),(\alpha +1,\beta +1),(\alpha +2,\beta )\}\subset S\), let \(u=(\alpha ,\beta )\) and \(v=\alpha +1,\beta +1)\). Since \((\alpha ,\beta +2)\in S\), if there is a shortest path in \(\widehat{G}\) from \(w_1\) to x going through the edge uv, then there is also a shortest path from \(w_1\) to x avoiding the edge uv, because Condition iv) of Lemma 1 is satisfied. Since \((\alpha +2,\beta )\in S\), if there is a shortest path in \(\widehat{G}\) from \(w_2\) to y going through the edge uv, then there is also a shortest path from \(w_2\) to y avoiding the edge uv, because Condition iv) of Lemma 2 is satisfied.

In all cases, the choice of the edge \(e=uv\) ensures that the graph \(H=\widehat{G}-e\) is connected, as is pointed out in Lemmas 1 and  2. In addition, \(d_{H}(z,\omega _i)=d_{\widehat{G}}(z,\omega _i)\), for every \(z\in S\) and \(i\in \{1,2\}\), and thus, \(\widehat{W}\) is a resolving set of H satisfying \(\{r(z\vert \widehat{W}):z\in V(H)\}=S\). Moreover, H and \(\widehat{G}\) are non-isomorphic graphs because they have different number of edges. Therefore, \((\widehat{G},\widehat{W})\) and \((H,\widehat{W})\) are non-equivalent realizations of S. \(\square \)