My Gallery recently had some serious database issues. I had to write some code outside of the Gallery proper to look for database errors. When I went to look for cycles in the tree, I didn't find any handy algorithms out in the wild of the internet, so I wrote something.
That produces this output:
Found cycle in 1:2,2:3,3:1
Found cycle in 1:2,2:3,4:1,3:4
Found cycle in 1:2,2:1
I hope that helps whomever might be searching for this very algorithm. Please note that this does not detect duplicate children or missing parents.
0 Responses to Detecting Cycles in Tree Structures with PHP
Leave a Reply