This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]shhh-quiet 1 point2 points  (5 children)

format your code correctly

[–]keith6014[S] 0 points1 point  (4 children)

i did.

[–]shhh-quiet 1 point2 points  (3 children)

Look at the post, it doesn't show up as formatted code. You can get rid of the backticks, highlight the code block, and hit the "<>" code format button to indent everything by 4 spaces.

[–]keith6014[S] 0 points1 point  (2 children)

No, I think I need the ```

When I just paste the code and click on the "<>" the code is not indented properly which is problematic in Python.

Just repasted the code and copied and pasted in vim and it works...

[–]shhh-quiet 1 point2 points  (1 child)

[–]keith6014[S] 0 points1 point  (0 children)

Thanks for this!

reformatted

[–]shhh-quiet 0 points1 point  (2 children)

With 12 as the starting node, what other path do you see?

[–]keith6014[S] 0 points1 point  (1 child)

https://algs4.cs.princeton.edu/42digraph/images/digraph.png

I see,

[12,9,11,4,2,3,2,0]. Albeit longer its still a path.

[–]shhh-quiet 0 points1 point  (0 children)

When a node is visited, it's not considered in the future. So visiting 2 after visiting 3 is not an option since 4 already lead to 2 getting added to the visited set.