Implement Bidirectional Dijkstra's algorithms in Java