You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. Nice one :) I used your algorithm and converted it into a class and it seems to fork well. I would like to suggest to put your code into a class which would be more handy for real life usage I think. See my example below (I am not sure why $G is modified so hopefully my class is working correctly)
Update: I also modified how the $G array is used - You expect indices to be continous 0-N while my situation was different. My indices are random IDs from DB. This is the only difference I forgot to mention.
Update2: I also converted internal variable $maxlooplength and hardcoded string '|' into private attributes with setters and getters so they can be configured. See example below.
Hello. Nice one :) I used your algorithm and converted it into a class and it seems to fork well. I would like to suggest to put your code into a class which would be more handy for real life usage I think. See my example below (I am not sure why $G is modified so hopefully my class is working correctly)
Update: I also modified how the $G array is used - You expect indices to be continous 0-N while my situation was different. My indices are random IDs from DB. This is the only difference I forgot to mention.
Update2: I also converted internal variable $maxlooplength and hardcoded string '|' into private attributes with setters and getters so they can be configured. See example below.
PS2: I would also like to ask for enhancement of linked article - I was missing graphical representation of the graph whose "Adjacency Matrix" is used.
https://www.vacilando.org/article/php-implementation-tarjans-cycle-detection-algorithm
Thank you for your contribution.
The text was updated successfully, but these errors were encountered: