*...*..D
.G..*.....
**...**.
.S....*.
........
...G**..
........
.G..*...
Here is 2d array where
S- Source
D-Destination
G-Point must be
Here there are many algorithms like dijkstra or BFS but if you need to learn an path finding algorithm then i suggest the A* algorithm as it is quicker than dijkstra or BFS and can be easily implemented on a 2D matrix.
As in case of must visit node you can try all sequences in which you visit the nodes for example say S->G1->G2->G3->D
find the minimum for this path as min(S,G1)+min(S,G2)+min(G3,D)
. try all permutations of the G's
and get the minimum of them all.