I know how to find the shortest path between two given nodes. However, I don’t know how to find the nodes that actually contain that shortest path apart from those two given nodes. (as the case maybe)

For example, if I have to find the shortest path b/w nodes 1 and 8 in a total of 8 given nodes, the shortest path contains the following nodes: 1, 4, 5, 7, 8 (for instance). So my question is: How do I find 4, 5 and 7 precisely??