NEC Corporation Interview Question

Uni-directional graph question in Java