Google interview question

Code challenge on javascript using graph