I have a problem for which I am not getting optimal answer from last 3 days Problem is as Below Given a graph G find the shortest distance between Source to Destination node but you MUST PASS THROUGH ALL THE NODES before going to destination BECAUSE THEY ALL are MUST_PASS nodes.
Additional info: - -you can pass any node more than once if required to get optimal answer - -max number of nodes is 22 including source & destination
What I tried so far - brute-force : simple permutation will give you the answer for small n , but since upper bound is 20, it is not practical 20! duhh :(
TSP with DP: problem with this is I Start from Source visit all nodes except destination & comes back to start, now if I go back to last node which I visited and from their if I go to destination one might think that this will give me optimal result, but the result is sub-optimal and not optimal ...:(
suppose each must_pass node is named as C, Start as S, destination as D, then one might thing f(S,D) = min(S,C1) + min(C1,C2) + min(C2,Ck) + min(Ck,D) but this is also sub-optimal and optimal for small graph with fewer MUST_VISIT nodes
Max Must_Visit nodes are 20