Can Q-learning be used to find the shortest distance from each source to destination?
Welcome to AI.SE Adarsh!

This is fairly simple to do with Q-Learning.

If you assign a reward equal to -1 for each location other than the goals, and 0 for the goals, then Q-learning with no discount factor will learn the length of the shortest path from each location to the goal. Alternatively, you can use a discounting factor, and then invert the equation on the learned values of the Q function to obtain the number of steps.

Hope this helps!