At <http://en.wikibooks.org/wiki/Real_Analysis/Metric_Spaces> you can find the standard definition of a metric space: a set $X$ given with a function $d:X\times X\to\mathbb{R}$ that satisfies properties 1 through 4. Later on the page it defines open ball and open set, and proves that arbitrary unions and finite intersections of open sets are open. (The page has a few mistakes; in particular, in the second paragraph of the proof, the unions should be intersections.) In other words, the open sets form a topology.


What I find remarkable is that none of properties 1 through 4 are needed for this proof. So consider a set $X$ and an arbitrary function $d:X\times X\to\mathbb{R}$. We can define open balls and open sets using the same definitions, producing a topology on $X$. Such topologies can be very different from those that arise from true metrics; for example, if $d$ is identically 0 we get the indiscrete topology.


Can we prove anything interesting about which topologies can arise this way? In particular, does every finite topology arise this way?



Topological spaces determined by generalized metric spaces
Some partial answers to OP´s original question:


1) Any first-countable space (and in particular **any finite topology**) can be obtained in this way.


Let $X$ be first-countable, and for each $x \in X$ fix a local neighborhood base $\{B\_n^x:n \in \omega \}$ such that $X=B\_0^x$ and $B\_{n+1}^x \subseteq B\_n^x$. We can now define the (not necessarily symmetric) function $$d(x,y)=\inf \left \{\frac{1}{n+1}:y \in B\_n^x \right \}.$$


It is not hard to see that the topology defined by this function (defining balls centered at $x$ as $B(x,\varepsilon):=\{y : d(x,y) < \varepsilon \}$) is the same as the original topology on $X$.


2) One can get non-first-countable topologies.


If we let $X=\{a\_{n,m} : n,m \in \omega \} \cup \{b\_n :n \in \omega\} \cup \{c\}$ and define $d(b\_n,a\_{n,m})=d(c,b\_n)=\frac{1}{n+1}$, $d(x,x)=0$ and $d(x,y)=1$ otherwise, we obtain Arens´ space which is first-countable at every point except at $c$.


3) Not every topology can be obtained in this way.


If $X=D \cup \{\infty\}$ is the one-point compactification of an uncountable discrete space, then the topology of $X$ cannot come from a "generalized metric". Just note that in this situation the balls $B(\infty,1/n)$ have to be open and hence cofinite; thus their intersection is cocountable and therefore the topology induced by the generilized metric wouldn´t be Hausdorff (but the original topology is).


**Edit:** here is another example for 3), prompted by Marcos´ comment, which is interesting because it shows that the class of spaces that we are looking at is not closed under subspaces: 


The Arens-Fort space, which is just the subspace $\{a\_{n,m} : n,m \in \omega \} \cup \{c\}$ of the Arens´ space defined in 2), can´t be obtained by this procedure. The reason is that the balls $B(x,\varepsilon)$ would have to be open (this is not hard to see) but then $\{B(c,1/n):n \in \omega\}$ whould be a countable local base at $c$. 


