Bidirectional search and termination condition in dijkstra_kernel