  Topological indices are parameters associated with graphs that have many
applications in different areas such as mathematical chemistry. Among various
topological indices, the Wiener index is classical \cite{w}. In this paper, we
prove a formula for the Wiener index and more general $m$-Steiner Wiener index
of an arbitrary graph $G$ in terms of the cardinalities of its twin classes. In
particular, we will show that calculating these parameters for the graph $G$
can be reduced to calculating the same for a much smaller graph (in general)
called the reduced graph of $G$.
  As applications of our main result, the $m$-Steiner Wiener index is
explicitly calculated for various important classes of graphs from the
literature including
  \begin{enumerate}
  \item[(a)] Power graphs associated with finite groups,
  \item[(b)] Zero divisor graphs and the ideal-based zero divisor graphs
associated with commutative rings with unity, and
  \item[(c)] Comaximal ideal graphs associated with commutative rings with
unity. \end{enumerate} We have also found an upper bound on the $m$-Steiner
Wiener index of an infinite class of graphs called the completely joined
graphs. As a corollary of this result, we explicitly calculate the $m$-Steiner
Wiener index of the complete multipartite graphs.
