the first path index is the starting node