title: Constrained shortest path in a graph
body: <p>Here is my problem I found in an online judge website: </p>
  
  <p>I have an undirected graph (with loops). We have k different classes of vertices in the graph. You can think of class 1 vertex being colored green, class 2 vertices colored red and so on. There is also a special class of vertices colored white (more later).</p>
  
  <p>Now, the user will specify a source vertex, a destination vertex, and a sequence of <strong>distinct</strong> vertex classes (non-white) eg.</p>
  
  <p>We are given source vertex 10, destination vertex 40, and a sequence: red->blue->black.</p>
  
  <p>We have to find the <strong>shortest path</strong> such that the path starts from vertex 10, touches 1 red vertex followed by 1 blue and 1 black vertex and then reaches vertex 40. The path, however, can have as many white vertices as needed. It can also traverse a white vertex twice. </p>
  
  <p>So a solution can be: 10->20(white)->35(red)->21(white)->22(white)->30(blue)->34(black)->40</p>
  
  <p>Incorrect:</p>
  
  <p>10->20(white)->30(blue)->21(white)->22(white)->35(red)->34(black)->40 (goes to blue before red)</p>
  
  <p>10->20(white)->35(red)->56(red)->21(white)->22(white)->30(blue)->34(black)->40 (goes through red twice)</p>