Dear sir.
I have full experience of c++ and algorithms.
I took part in ACM ICPC in university so I know many algorithms.
Your problem is solved with Shortest path algorithms
I just joined in freelancer but I started long ago,
If I understand your problem , I can solve for 1 hours.
Thanks sir.