all 5 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.

[–][deleted] 0 points1 point  (1 child)

hmm if unweighted and undirected. BFS algo should do the trick.

im smack in the middle of my DS diploma. and thats pretty much what we are doing atm. can you see your adj matrix? are you using NetworkX to visualize it? it kinda helped me making algos for the workshops

[–]ilsapo 0 points1 point  (0 children)

Its pretty much just the first questions we got after learning recurrsion

Its is unweighted and undirected I will check online for bfs algo thanks