Leetcode Complete Graph Algorithm In Python