my code>> https://ide.codingblocks.com/s/480332
Can u plz help why my dfs approach not giving desired result I tried but couldn’t find error
my code>> https://ide.codingblocks.com/s/480332
Can u plz help why my dfs approach not giving desired result I tried but couldn’t find error
hello @joshisanjay8467
add self edges as welll
ie if a—b is edge then
add -> a–a value 1
b–b value 1
bhaiya that will be handled in dfs_helper if both src and dest is same I am returning 1 in that case
for A-> B weight is x so for B->A I saved as 1/x;
Now if I want to find B->A so src will become B and src nbrs will be A and I have saved the weight from B->A will be dist from B->A multiply dist(A->A) so should give me required result that’s what my dfs is doing but couldn’t figure out in code where I have made mistake
your dfs will stop just after iterating first neigbour , if it return -1.
sine u have to try all paths remove else part from the loop
tried it but still B->A is giving 0.00
pls wait , it might take some time
no problem bhaiya !! I will wait
make it double
small mistake!! but thankyou bhaiyaa for figuring it out I spent more than 1hr figuring out error!!
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.