Path create algorithm.