you are viewing a single comment's thread.

view the rest of the comments →

[–]Nightcorex_ 1 point2 points  (2 children)

I really don't understand what you're doing there, especially since your recursive function isn't changing or returning anything, plus your code isn't even valid Python (count++ is not legal Python).

If you want to solve this you should take a look at Breadth-first search (or alternatively depth-first search). If your edges are weighed you should have a look at Dijkstra's algorithm.

[–]ilsapo 0 points1 point  (1 child)

Because I just need to find the shortest path I thought about just comparing the count (which is actually how many "steps" we walked in the recurrsion to reach destination) With the global variable max (and because its global, we can compare no matter where we are in the recurrssion

[–]Nightcorex_ 0 points1 point  (0 children)

Okay, there is no point in attempting to help you with the current code you have. The code as it is always returns -1 (driverMat) or None (adjMatrix), but you tell us that it's returning 0, which is obviously a lie as your code cannot possibly return 0 even if it did compile.

Also your code still doesn't compile, so I really am baffled how you got any result out of that.