NEC Corporation interview question

Uni-directional graph question in Java