HOW TO PRINT PATH IN DIJKSTRA ALGO WITH A TEMPLATED CLASS?

Here is the link to my code : https://ide.codingblocks.com/s/452461

Can someone please tell how to print path , I’m not able to print the whole path ,just the last node prior to the destination

1 Like

hello @Vishesh-Chaitanya-1475805525886480

u can store parent node of each node in some map and then use that information to find the path.
refe this discussion ->

check this code->

1 Like

Got it ,Thankyou so much @Aman Yadav

Just a small doubt here, this code is hard coded by taking Delhi as the source , what if i change the source and then try to print the path for a particular city

u can modify the print function as per ur need.
just replace delhi with source

I’m sorry, it was a petty doubt , nevermind

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Thank you Aman. I was stuck in this problem for quite some time.