why is this code not giving correct output for the input given in the code…plz tell the problem and correct the code as well…
Dijkshitra algorithm problem
also tell how to print the min diatnce path to all dest from source using a parent array…in this code only…
@S19LPPP0202 its giving correct output if you are wondering why delhi to amritsar is 0 thats because you are joining only 1 directed edge otherwise wont be possible for some cases here take a look i have added bidirected edge
does dijkstra work only for bidirectional graphs and not for directed graphs??
plz tell the reason as well…
no it was working fine for single direction fpr your code too
if it was working fine for single direction then why it was showing wrong input for delhi as zero??
plz tell on what all types of graphs can dijkstra algo be implemented??plz ans both the ques…
delhi is 0 because Amritsar to delhi there was way while delhi to amritsar not thats why
djisktra can be worked for directed uni or bi graphs also distance of weights should be positive . if neg djikstra dont work
@S19LPPP0202
my starting source was amritsar and if Amritsar to delhi there was way then it should have output that distance as output then…
but as you can see its giving correct on using bidirected only so i think its the error .
will see it one more time and tell you
Plz see and let me know because this is a conceptual error as well and I would like to clear it …
but as you can see its giving correct on using bidirected only so i think its the error . This is definitely not the reason as it would mean that Dijkstra will not work on directed graphs which contradicts your own statement…
@S19LPPP0202 the problem was very small. actually dist of delhi was not setting to int_max as delhi dont have any children so it was not in the graph as a key. just set its dist to int max ans will come
what was the error ??
read above i have written @S19LPPP0202
the problem was very small. actually dist of delhi was not setting to int_max as delhi dont have any children so it was not in the graph as a key. just set its dist to int max ans will come
yeah thanks for correcting the mistake …
by the way i was also facing problem in prims implementation i have posted a seperate doubt for that if u could clear it now it would be very helpful…
link of doubt :
hey just mark this as resolved someone will acknowledge that doubt
i haven’t studied prim algo otherwise would have cleared it @S19LPPP0202