I am trying to implement Dijkstra\'s algorithm which can find the shortest path between the start node and the end node. Before reach the end node there are some \'must-pass
This is a generalisation of the travelling salesman problem. The TSP comes up as the case where all vertices are "must-pass".
Find shortest paths between each pair of must-pass vertices, from the source to each must-pass vertex, and from each must-pass vertex to the sink. Then use the famous O(n 2^n) dynamic programming algorithm for TSP to find the shortest path from source to sink meeting your constraints; here n will be two plus the number of must-pass vertices.