We say that a binary operation $*$ is associated with a (finite undirected) graph $G$ (without loops and multiple edges) if $*$ is defined on $V(G)$ and $uv\in E(G)$ if and only if $u\ne v$, $u * v=v$ and $v*u=u$ for any $u$, $v\in V(G)$. In the paper it is proved that a connected graph $G$ is geodetic if and only if there exists a binary operation associated with $G$ which fulfils a certain set of four axioms. (This characterization is obtained as an immediate consequence of a stronger result proved in the paper).