add generate_pathmatrix function