Trying to implement shortest distance equation.
Added a link for another possible solution to the shortest distance issue.