My graph theory textbook gives the definition of a 'metric' as:
- $M(x,y) \ge 0$ for all $x$, $y$, and $M(x,y) =0$ if and only if $x=y$;
- $M(x,y) = M(y,x)$ for all $x,y$;
- $M(x,y) \le M(x,z) + M(z,y)$ for all $x,y,z$.
When I see properties like this I try to construct basic functions that break only one of the rules at a time, while leaving the others intact. That gives me a good feel for how they play off one another.
So I tried the function
\begin{equation} M(x, y) = \left\{\begin{matrix} 0 & \text{when} \quad x = y \\ 1 & \text{when} \quad x \neq y \\ \end{matrix}\right. \end{equation}
This seems to satisfy all the properties, though, except for maybe the third one! But it feels like it goes against the "spirit" of a metric somewhat.
Is there a counterexample I'm not seeing here? Many thanks in advance.
The function you provide is indeed a metric, and it satisfies the third condition as well: if $x=y$, $M(x, y)=0$ and the inequality is satisfied; if instead $x\ne y$, surely one of $z\ne x$ or $z\ne y$ must be true, so you have $M(x,z)+M(z,y)\ge1$.
The metric you have found is called discrete metric, and is a particular example of metric that induces a discrete topology on the set equipped with it. If a set $X$ is endowed with this topology, all of its subsets are open in the topology, and as a consequence all functions from $X$ to another topological space is a continuous map.