Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Graph doesn't need to cycle to hit a node twice. Good code does not visit the same node twice.


When doing recursion (Postgres recursive CTE) I keep a path on the latest edges and check to see new edges aren't already visited, so same nodes can appear in multiple branches but not on the same branch. Works flawlessly.


Can you provide an example of this? I’d like to understand this technique.

Edit: is this an example? https://stackoverflow.com/a/1757915




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: