Let M-(n) be a graph which is obtained from a path P-n or a cycle C-n
by replacing each vertex by a fixed graph M and replacing each edge by
a fixed set of edges joining the corresponding copies of M. A matrix
approach to the computation of distance-related invariants in such gra
phs is presented. This approach gives a general procedure to obtain cl
osed formulas (depending on n) for such invariants of M-(n). As an exa
mple, the Wiener index is treated in more detail.