After a small research I figured out that this problem is NP-Hard. Therefore I had to use the parametrization technique to solve this problem. The algorithm that I used out is a fixed parameter tractable algorithm.
I used the Lawler's modification of the Yen's algorithm in my algorithm to solve this problem. Yen's algorithm helps to find out the first n shortest paths in a loop-less network. Here is how my algorithm goes:
Get the parameter k (the number of vertices in the path) from the user. Also get 'm', from the user, which is the maximum distance that the path should not exceed. This is the parameter that is going to help us solve the NP-Hard problem in polynomial time.
This step uses the Yen's algorithm. Find the next shortest path. Check if the path has k vertices.
a. If yes, abort and return the path
b. Else, 2
If the total distance of the path exceeds the parameter 'm', then abort and return 'no result'
The Yen's algorithm uses Dijkstra's algorithm to find the shortest path. It was fun implementing this algorithm to solve this problem.