Let $W(G)$ be the sum of distances between all pairs of vertices of a graph $G$. For an edge $e$ of $G$, connecting the vertices $u$ and $v$, the number $n_u(e)$ counts the vertices of $G$ that lie closer to $u$ than to $v$. In this paper we consider the graph invariant $W^\ast(G)=\sum_e n_u(e)n_v(e)$, defined for any connected graph $G$. According to a long-known result in the theory of graph distances, if $G$ is a tree then $W^\ast(G)=W(G)$. We establish a number of properties of the graph invariant $W^\ast$.