Google Cloud interview question

Graph questions a hard one from leetcode.