Generalizations of Wiener polarity index and terminal Wiener index
  In theoretical chemistry, distance-based molecular structure descriptors are used for modeling physical, pharmacologic, biological and other properties of chemical compounds. We introduce a generalized Wiener polarity index $W_k (G)$ as the number of unordered pairs of vertices ${u, v}$ of $G$ such that the shortest distance $d (u, v)$ between $u$ and $v$ is $k$ (this is actually the $k$-th coefficient in the Wiener polynomial). For $k = 3$, we get standard Wiener polarity index. Furthermore, we generalize the terminal Wiener index $TW_k (G)$ as the sum of distances between all pairs of vertices of degree $k$. For $k = 1$, we get standard terminal Wiener index. In this paper we describe a linear time algorithm for computing these indices for trees and partial cubes, and characterize extremal trees maximizing the generalized Wiener polarity index and generalized terminal Wiener index among all trees of given order $n$. 
Aleksandar Ilic and Milovan Ilic
math.CO