Update answer to problem 117.

- Use explicitly graph concepts.
- Narrow the graph to valid paths, add labels to edges.