**Note**: This answer takes the definition of a metric basis as an *inclusion-minimal* metric generating set. This definition is **non-standard**. [Another answer][1] deals with the same topics but takes the standard view of metric bases as *cardinality-minimal* metric generating sets. Let's define the *weak metric dimension* of a metric space to be the common size of all *inclusion-minimal* generating sets, if this common value exists. First I'll characterize those finite metric spaces with well-defined weak metric dimension in terms of the purity of a related [simplicial complex][2] and then briefly talk about how [matroids][3] fit into the picture. # Simplicial Complex Background We will need some terminology for (abstract) [simplicial complexes][2]. A _simplicial complex_ on a set $S$ is a collection of subsets $\Delta$ of $S$ that is closed under taking subsets, that is, if $T \in \Delta$ and $T' \subseteq T$, then $T' \in \Delta$. The elements of $\Delta$ are called its _faces_ and the inclusion-maximal faces are the _facets_ of $\Delta$. The _rank_ of a face $F$ is given by $r(F)=\#F$ and the _rank_ of $\Delta$, denoted $r(\Delta)$, is the largest rank of a face in $\Delta$. Note that for a general simplicial complex, the cardinality of two facets need not be equal. (Example: $([3], \{\emptyset, 1, 2, 3, 23\})$.) However, if all facets do have the same cardinality the simplicial complex is called _pure_. # A (nearly trivial) characterization Let $(M,d)$ be a _finite_ metric space and let $\mathcal{G}$ be the collection of all generating sets for $(M,d)$. Define the set $$\Delta = \Delta(M,d) := \{M \setminus G~|~G \in \mathcal{G}\}.$$ Note that if $G' \supseteq G$ and $G \in \mathcal{G}$ then $G' \in \mathcal{G}$. This impies that the set $\Delta$ is an abstract simplicial complex on $M$. The facets of $\Delta$ correspond to *inclusion-minimal* generating sets of $(M,d)$ by set complementation. So the metric dimension of the finite metric space $(M,d)$ is well-defined (using this nonstandard definition) if and only if the complex $\Delta(M,d)$ is pure. In this case, $\dim(M,d) = \#M - r(\Delta)$. # Example Now let me try to tie this into the discussion of Example 1 of [this answer][4] to the [previous question][5]. In that example we have $M = \{0,1,2,3\}$ and $d$ given by $$d(x,y) = \begin{cases} 2 \text{ if } x,y \neq 0 \\ 2 + \frac{1}{y} \text{ if } x = 0. \end{cases}$$ One computes that the metric generating sets consist of all subsets of $\{0,1,2,3\}$ except for the empty set and the singletons $\{i\}$ where $i \in [3]$. So $\Delta(M,d)$ is the simplicial complex whose faces are arranged by containment in the following poset. So $\Delta(M,d)$ is not pure (it has three facets of rank two and a facet of rank three) and so the metric dimension (using this nonstandard definition) of $\Delta(M,d)$ is not well-defined. [![The face poset of $Delta(M,d)$][6]][6] Let us note that using the standard definition of metric dimension $(M,d)$ has metric dimension one since its only metric basis is $\{0\}$; see [this answer][1] to this post for more on the standard case. # Matroids For an arbitrary finite metric space $(M,d)$, the complex $\Delta(M,d)$ is a matroid (that is, its facets satisfy the basis exchange axiom for matroids) if and only if the "matroid dual" complex $$\Delta^*(M,d) := \{H \subseteq G | G \text{ is inclusion-minimal in } \mathcal{G}\}$$ is a matroid. In this case the metric dimension of $(M,d)$ is just the rank of $\Delta^*(M,d)$. Let $f(n)$ be the number of simple, connected graphs on $n$ and $g(n)$ be the number of such graphs such that the weak metric dimension on the natural metric space $M(G)$ is well-defined. Also, let $h(n)$ be the number of those graphs counted by $g(n)$ whose weak metric bases are matroidal. Then using some [Macaualay2 scripts][7] we have the following values. n = 1 2 3 4 5 6 7 f(n) = 1 1 2 6 21 112 853 g(n) = 1 1 2 5 17 69 437 h(n) = 1 1 2 5 16 61 290 One should compare this table to the similar table in [this answer][1]. [1]: https://mathoverflow.net/a/278025/94968 [2]: https://en.wikipedia.org/wiki/Abstract_simplicial_complex [3]: https://en.wikipedia.org/wiki/Matroid [4]: https://mathoverflow.net/questions/275493/when-does-a-metric-space-have-infinite-metric-dimension-definition-of-metric/275771#275771 [5]: https://mathoverflow.net/questions/275493/when-does-a-metric-space-have-infinite-metric-dimension-definition-of-metric [6]: https://i.sstatic.net/fD3Zp.png [7]: https://github.com/aarondall/MetricSpaces.m2