Continued step 5b implementation.

Added code for computing the shortest path from v to g (last part of
step 5bi).