title: How to find the shortest path in a graph, that has to go through a list of points and go back to the start?
body: <p>I am working on a coding problem, in which you are given an undirected, unweighted graph, a starting point and a list of points which you have to visit. The graph has n nodes and n-1 edges. How can I find the shortest distance of the path that starts at node 1, goes through all the points in the list, and finishes at node 1. Going through the same node/edge several times is allowed.</p>
  <p>INPUT:
  First row: integer n denoting how many nodes total (numbered 1-n), then integer k denoting how many must-visit nodes there are.
  Second row: k integers denoting the must-visit nodes
  Next lines: pairs of integers denoting there is an edge between them</p>
  <p>OUTPUT: length of shortest path as described</p>
  <p>EXAMPLE:
  In:
  5 2
  4 5
  1 2
  2 3
  2 4
  1 5</p>
  <p>Out:
  6</p>
  <p>I was thinking of finding the shortest path between node 1 and all must-visit nodes (for eg. using Djikstra), but I am not sure where to go from there.
  Python code would be appreciated.</p>