1 Introduction
Metric dimension is a graph parameter with many applications including robot navigation, chemistry, pattern recognition, image processing, and locating intruders in networks
[4, 1, 5, 6, 2]. In particular for the application to robot navigation [4], the robot is assumed to be moving from vertex to vertex in a graph, where some of the vertices are distinguished as landmarks. The robot is able to determine its distance to each landmark, and it uses those distances to determine its location in the graph. The goal is to use as few landmarks as possible, and the number of landmarks used is the metric dimension.Recently, a parameter closely related to metric dimension was defined in [3]. Imagine that the robot now moves from edge to edge instead of vertex to vertex. The robot can still determine its distance from the landmarks, where the distance from an edge to a landmark is the minimum of the distance from or to the landmark. Again the goal is to use as few landmarks as possible, and that number is the edge metric dimension.
A number of results relating pattern avoidance and metric dimension have been proved in the last few decades, but perhaps the most famous one is the result of Khuller et al [4] that no graph of metric dimension contains as a subgraph (and more generally, that graphs of metric dimension cannot have as a subgraph). More generally, Sudhakara and Kumar proved an upper bound of on the number of vertices in subgraphs of diameter in graphs of metric dimension [8].
Besides pattern avoidance, researchers have also investigated the maximum size of graphs with a given diameter and metric dimension. In particular, Hernando et al [7] proved that the maximum possible number of vertices in a graph of diameter and metric dimension is at most . Kelenc et al [3] proved that graphs with edge metric dimension and diameter have at most edges. Later, Zubrilina sharpened the bound for edge metric dimension to [9].
Kelenc et al [3] also bounded the edge metric dimension of several classes of graphs, including dimensional grid graphs and dimensional hypercube graphs. They asked for a characterization of all graphs with edge metric dimension , which Zubrilina found [9]. Using the characterization, Zubrilina proved that such graphs have diameter at most . Furthermore, Zubrilina asked for a characterization of all graphs of edge metric dimension .
In this paper, we prove several new bounds related to pattern avoidance, metric dimension, and diameter. We also answer Zubrilina’s question and show that vertex graphs with edge metric dimension have diameter at most . Before stating more details about our results, we first discuss some terminology.
1.1 Terminology
All graphs in this paper will be simple and connected. Let denote the distance between and for any vertices
. The distance vector
of a vertex with respect to a set of vertices is the vector with coordinates which has a single coordinate with value for each vertex . A set of vertices is a metric basis for (the vertices of) if no two vertices in have the same distance vector with respect to . In some papers, the metric basis is called a resolving set. The metric dimension is the minimum size of a metric basis for .For any vertex and edge such that , let . The distance vector of an edge with respect to a set of vertices is the vector with coordinates which has a single coordinate with value for each vertex . A set of vertices is a metric basis for the edges of if no two edges in have the same distance vector with respect to . The edge metric dimension is the minimum size of a metric basis for the edges of .
The chromatic number of a graph is the minimum number of colors required to label the vertices of so that no edge has two vertices of the same color. The degeneracy of a graph is the minimum such that every subgraph of has a vertex of degree at most within the subgraph. We will call a nonmutual neighbor of vertices if is adjacent to or , but not both.
1.2 New results
In Section 2, we prove that the maximum possible number of edges in a graph of diameter and edge metric dimension is at most . This sharpens the bound of from Zubrilina [9], which improved on the bound of Kelenc et al [3]. We also prove that there is no subgraph of diameter with more than vertices in any connected graph of metric dimension , and there is no subgraph of diameter with more than edges in a connected graph of edge metric dimension .
In Section 3, we derive several results about specific forbidden subgraphs in graphs of metric dimension or edge metric dimension . We prove that the maximum value of such that a graph of metric dimension can contain as a subgraph is . We also prove that the maximum value of such that a graph of metric dimension or edge metric dimension can contain as a subgraph is .
In the same section, we show that the maximum value of such that a graph of edge metric dimension can contain as a subgraph is . We also show that the maximum value of such that a graph of metric dimension can contain as a subgraph is between and . Using these bounds, we prove that the maximum possible chromatic number and degeneracy of a graph of metric dimension is .
In Section 4, we prove that the dimensional grid has edge metric dimension at most . This bound generalizes the results of Kelenc et al (2016) that nonpath grids have edge metric dimension and that dimensional hypercubes have edge metric dimension at most . In addition, we provide a characterization of vertex graphs with edge metric dimension . This answers a question of Zubrilina, and as a result of this characterization, we prove that any connected vertex graph such that has diameter at most . In general, we prove that any connected vertex graph with edge metric dimension has diameter at most .
2 Bounds in terms of diameter and dimension
The next proof is very similar to the proof in [7] that the maximum possible order of a graph of diameter and metric dimension is equal to .
Theorem 2.1.
The maximum possible number of edges in a graph of diameter and edge metric dimension is at most .
Proof.
Let be a graph of diameter and edge metric dimension . Let be a metric basis for the edges of and let be a constant that will be chosen at the end. For each and , define .
First note that for any two edges and any vertex , so and has possible values for each such that . Thus .
Consider such that for all and , i.e., for all . Since only has entries between and inclusive, there are at most such edges. Thus
Setting gives the upper bound. ∎
We use both of the theorems below for the pattern avoidance results in the next section. The first result generalizes the proof for the case from [8].
Theorem 2.2.
There is no subgraph of diameter with more than vertices in any connected graph of metric dimension .
Proof.
Let be a subgraph of diameter in a connected graph of metric dimension with minimal metric basis . For each vertex in , each coordinate of has at most possible values, since has diameter . Thus there are at most vertices in . ∎
The next result and proof are analogous to the last, with edge metric dimension replacing the usual vertex metric dimension.
Theorem 2.3.
There is no subgraph of diameter with more than edges in any connected graph of edge metric dimension .
Proof.
Let be a subgraph of diameter in a connected graph of edge metric dimension with minimal edge metric basis . For each edge in , each coordinate of has at most possible values, since has diameter . Thus there are at most edges in . ∎
3 Specific forbidden patterns, chromatic number, and degeneracy
The upper bound in the first theorem below is well known [4]. We prove a matching lower bound to show that it is sharp.
Theorem 3.1.
The maximum possible value of such that a graph of metric dimension can contain as a subgraph is .
Proof.
For the lower bound, define to be the graph obtained from by adding vertices with edges defined as follows: For each vertex in the copy of , label with a binary string of length . For each of the new vertices , add an edge from to if the digit of is .
First note that the metric dimension of is at least since contains a complete subgraph with vertices. If we set , then is one more than the digit of for each and all in the copy of . Moreover each is the only vertex in with , so is a metric basis for . ∎
Both of the next two results give bounds on the number of edges in graphs of metric dimension or edge metric dimension , as well as corollaries about the chromatic number and degeneracy.
Theorem 3.2.
The maximum possible value of such that a graph of edge metric dimension can contain as a subgraph is .
Proof.
The upper bound was proved in [3], but we mention the argument for completeness. Let be a subgraph isomorphic to of a graph of edge metric dimension . For all edges , each coordinate of has at most possible values. Thus has at most edges.
For the lower bound, define to be the graph obtained from with center vertex by adding vertices with edges defined as follows: For each noncenter vertex in the copy of , label with a binary string of length . For each of the new vertices , add an edge from to if the digit of is .
First note that the edge metric dimension of is at least since contains a star with noncenter vertices. If we set , then is one more than the digit of for each and all noncenter vertices in the copy of .
All other edges are adjacent to some and thus have . For each , is one more than the digit of , where is the vertex such that . Thus is a metric basis for the edges of . ∎
The next result shows that the bound in Theorem 2.2 is not far from the exact value for .
Theorem 3.3.
The maximum possible value of such that a graph of metric dimension can contain as a subgraph is between and .
Proof.
The upper bound follows from Theorem 2.2, since has diameter .
For the lower bound, define to be the graph obtained from with center vertex by adding vertices with edges defined as follows: For each noncenter vertex in the copy of , label with a base string of length . Add an edge from to if the digit of is . Also add an edge from to , and add an edge from to if the digit of is .
If we set , then is one more than the digit of for each and all noncenter vertices in the copy of . Moreover for each , is the only vertex such that .
Each has distinct from for all , but it is possible that for some noncenter vertex in the copy of , or that where is the center vertex in the copy of . Note that every coordinate of is , so is distinct from for each .
Let be the graph obtained from by deleting any noncenter vertex in the copy of such that or for some . There are at most such vertices , so contains a star with at least noncenter vertices. By definition, is a metric basis for . ∎
Next we bound the size of complete bipartite subgraphs in graphs with bounded metric dimension or edge metric dimension.
Theorem 3.4.
The maximum possible value of such that a graph of metric dimension can contain as a subgraph is .
Proof.
The upper bound follows from Theorem 2.2 since has diameter and vertices.
For the lower bound, define to be the graph obtained from by adding vertices with edges defined as follows: For each vertex on the left side of the copy of , label with a binary string of length , and do the same with each vertex on the right side of the copy of . For each , add an edge from to on the left side of the copy if the digit of is and add an edge from to on the right side of the copy if the digit of is .
Set to consist of the new vertices and suppose that for vertices . If there exists such that , then . Otherwise for all , so was a vertex in the copy of . Since , and are both adjacent to the same elements of , so unless and were both labeled with allones binary strings. We delete the vertices on each side that were labeled with allones binary strings. This gives a lower bound of . ∎
Theorem 3.5.
The maximum possible value of such that a graph of edge metric dimension can contain as a subgraph is .
Proof.
The upper bound follows from Theorem 2.3 since has diameter and edges. For the lower bound, define to be the same graph as in Theorem 3.4, before we deleted the vertices on each side that were labeled with allones binary strings.
Set to consist of the new vertices and suppose that for edges . If there exists such that , then is adjacent to , so was an added edge. Let be the other vertex besides in the edge . Note that for all such that , we have . There are edges adjacent to , and each such edge satisfies for all such that , where is the other vertex in edge besides . Thus each of the edges adjacent to has distinct distance vectors, so .
Now suppose that there does not exist such that . Thus was an edge from the copy of . Since , the left vertices in and are adjacent to the same elements of , and the right vertices in and are adjacent to the same elements of . Thus and have the same left and right vertices, so . This gives a lower bound of . ∎
Using the pattern avoidance bounds, we have several corollaries about the number of edges, chromatic number, and degeneracy.
Corollary 3.6.
The maximum number of edges in a connected graph of order and metric dimension is at most .
Proof.
The maximum possible degree of any vertex in a connected graph of metric dimension is at most by Theorem 3.3, and the number of edges is half the sum of the degrees. ∎
Corollary 3.7.
The maximum number of edges in a connected graph of order and edge metric dimension is at most .
Corollary 3.8.
The maximum possible chromatic number of any graph of metric dimension is between and .
Proof.
For the upper bound, list the vertices of the graph in any order. Greedily color them with colors, using a free color for each successive vertex since it has at most neighbors. For the lower bound, note that we showed in Theorem 3.1 that there exists graphs of metric dimension that contain as a subgraph. ∎
Corollary 3.9.
The maximum possible degeneracy of any graph of metric dimension is between and .
Proof.
For the upper bound, note that every subgraph contains a vertex of degree at most for the stronger reason that every vertex in the graph has degree at most . For the lower bound, observe that the graph in Theorem 3.1 has degeneracy at least its minimal degree, which is . ∎
Corollary 3.10.
The maximum possible degeneracy of any graph of edge metric dimension is between and .
Proof.
For the upper bound, note that every subgraph contains a vertex of degree at most . For the lower bound, observe that the graph in Theorem 3.5 has degeneracy at least its minimal degree, which is . ∎
4 Miscellaneous results
Kelenc et al [3] proved that dimensional grids have edge metric dimension at most and that the dimensional cube has edge metric dimension at most . The result below generalizes both of these results.
Theorem 4.1.
The dimensional grid graph has edge metric dimension at most .
Proof.
We prove this for the case that for all , since that suffices to imply the theorem. We identify vertices with points in dimensional space with integer coordinates such that the coordinate is between and inclusive. There is an edge between two points only if those points agree on all but one coordinate, and the points have a difference of in that coordinate. Let be the set consisting of the vertices , , , , , where each vertex has coordinates.
We write edges of the grid graph in the form , where for all . Suppose that two edges and have the same distance vector with respect to .
By definition, for the coordinate of the distance vector corresponding to the vertex . Moreover, for all .
If we subtract the first equation from each of the other equations, we obtain for all . Since and , we have and for all .
Combining the last fact with the first equation, we obtain . Thus , or else or would not be an edge. We proved that , so is a metric basis for the edges of . ∎
Zubrilina gave the following characterization of graphs of order and edge metric dimension and asked for a characterization of graphs of order and edge metric dimension .
Theorem 4.2.
[9] Let be a graph with . Then if and only if for any distinct there exists such that , , and is adjacent to all nonmutual neighbors of .
We provide a characterization of the graphs of order and edge metric dimension below, using a similar method to the one in Zubrilina’s proof.
Theorem 4.3.
If is a connected graph of order , then if and only if for all triples of vertices from there exists an ordering of the triple such that

is adjacent to both and and all nonmutual neighbors of are adjacent to , or

for some , is adjacent to both and , all nonmutual neighbors of in are adjacent to , and any that satisfies or also satisfies .
Proof.
We first show that graphs of order with edge metric dimension have the above properties. Suppose that is a graph of order with . Therefore for any distinct triple of vertices from , the set is not a metric basis for the edges of . Fix a and let . Since is not a metric basis for the edges of , there must exist two distinct edges such that . If there was a vertex in that is adjacent to exactly one of or , then and would have different distance vectors with respect to . Thus there exists an ordering of such that and , or there exists such that and .
In the first case where and , suppose that some vertex is a nonmutual neighbor of . Thus , so must be adjacent to or else and would have different distance vectors with respect to .
In the second case where and , suppose that some vertex is a nonmutual neighbor of . Then must be adjacent to or else and would have different distance vectors with respect to .
Moreover for the second case, suppose that some vertex satisfies or . Since and have the same distance vector with respect to , we must have . This completes the first direction of the proof.
For the other direction, we will show that any connected vertex graph with the properties listed above has edge metric dimension at least . Let be a set of vertices from , and suppose that is the triple of vertices not in . By assumption, there exists an ordering of such that

is adjacent to both and and all nonmutual neighbors of are adjacent to , or

for some , is adjacent to both and , all nonmutual neighbors of in are adjacent to , and any that satisfies or also satisfies .
In the first case, the edges and have the same distance vector with respect to because all nonmutual neighbors of are adjacent to . For the second case, suppose for contradiction that there exists such that .
Without loss of generality, suppose that . Then . There is a vertex on a minimal path from to that is the closest vertex in to . Thus either and , or and and and .
If and , then is a nonmutual neighbor of , so , which contradicts the fact that . If and and and , then , so , which again contradicts that . ∎
Note that if denotes the property equivalent to being a connected vertex graph of edge metric dimension in Theorem 4.2 and denotes the property equivalent to being a connected vertex graph of edge metric dimension in Theorem 4.3, then is equivalent to being a connected vertex graph of edge metric dimension .
We bound the diameter of connected vertex graphs of edge metric dimension below, using the characterization proved in the last theorem.
Theorem 4.4.
If is a connected vertex graph such that , then has diameter at most .
Proof.
Suppose for contradiction that has diameter at least . Then there exist vertices which form a shortest path (in order) between and . Thus , , and . This contradicts the fact from the last theorem that in any connected vertex graph of edge metric dimension , among any three vertices there must exist two vertices such that . ∎
Part of the characterization for vertex graphs of edge metric dimension can be generalized to graphs of edge metric dimension to give an upper bound of on the diameter.
Lemma 4.5.
If is a connected graph of order with , then for all tuples of vertices from , there exists an ordering of the vertices in such that .
Proof.
Suppose that is a graph of order with . Therefore for any distinct tuple of vertices from , the set is not a metric basis for the edges of . As in the proof for , fix a and let . Since is not a metric basis for the edges of , there must exist two distinct edges such that . If there was a vertex in that is adjacent to exactly one of or , then and would have different distance vectors with respect to . Thus there exists an ordering of such that and , or and , or there exists such that and . In each case, . ∎
Theorem 4.6.
If is a connected vertex graph such that , then has diameter at most .
Proof.
Suppose for contradiction that has diameter at least . Then there exist vertices which form a shortest path (in order) between and . Define . Observe that for all such that . This contradicts the fact from the last lemma that in any connected vertex graph of edge metric dimension , among any vertices there must exist two vertices such that . ∎
5 Conclusion and open problems
We found exact bounds for the maximum value of such that a graph of metric dimension can contain the complete graph and the maximum value of such that a graph of edge metric dimension can contain . However, for all of the other bounds in this paper, there is a gap between the upper and lower bounds.
We characterized vertex graphs with edge metric dimension and proved that they have diameter at most . We also proved that vertex graphs with edge metric dimension have diameter at most . Two natural problems are to characterize vertex graphs with edge metric dimension for fixed , and to find the exact value for the maximum possible diameter of an vertex graph of edge metric dimension .
One quantity that we did not bound in this paper is the maximum value of such that a graph of edge metric dimension can contain the complete graph . Since the edge metric dimension of is , there is a lower bound of . Since the complete subgraph can have at most edges by the pattern avoidance diameter bounds in Section 2, there is an upper bound of . What is the exact value of ?
We also found an upper bound of on the edge metric dimension of dimensional grid graphs . A related open problem is to find the maximum possible edge metric dimension for a graph of the form .
References
 [1] Gary Chartrand, Linda Eroh, Mark A. Johnson, and Ortrud R. Oellermann. Resolvability in graphs and the metric dimension of a graph. Discrete Appl. Math., 105(1):99–113, 2000.
 [2] Frank Harary and R. A. Melter. On the metric dimension of a graph. Ars Combin., 2(191195):1, 1976.
 [3] A. Kelenc, N. Tratnik, and I. G. Yero. Uniquely identifying the edges of a graph: the edge metric dimension. ArXiv eprints, jan 2016.
 [4] Samir Khuller, Balaji Raghavachari, and Azriel Rosenfeld. Landmarks in graphs. Discrete Appl. Math., 70(3):217–229, 1996.

[5]
R. A. Melter, I. Tomescu, Metric bases in digital geometry, Computer Vision, Graphics, and Image Processing 25 (1) (1984) 113–121.
 [6] P. J. Slater, Leaves of trees, Proceeding of the 6th Southeastern Conference on Combinatorics, Graph Theory, and Computing, Congressus Numerantium 14 (1975) 549–559.
 [7] M. Hernando, M. Mora, I. Pelayo, C. Seara, and D. Wood. Extremal Graph Theory for Metric Dimension and Diameter. Electr. J. Comb. 17(1), 2010.
 [8] G. Sudhakara and A. Kumar. Graphs with metric dimension two  a characterization. World Academy of Science, Engineering and Technology: International Journal of Mathematical and Computational Sciences 3(12), 2009.
 [9] N. Zubrilina. On the edge dimension of a graph. Discrete Mathematics 341(7): 20832088, 2018.