Longest paths joining given vertices in a graph