No guarantees that it is correct, but I would at least try the following:
- Find the shortest path from i to j.
- Remove all edges from the non-endpoint nodes on that path.
- Find a new shortest path from i to j.
No guarantees that it is correct, but I would at least try the following: