Shortest Path Leetcode Graph Valid