Reputation: 11
I want the user to be able to change the parent of a node. However, there has to be some check so that the loop situation does not arise. For eg. Parent of 9 is 8. Parent of 8 is 7. User might assign the parent of 7 as 9. In this situtation the tree will be in a never ending loop.
I have thought of a simple solution which is that while changing the parent I will check in PHP, if the new parent node id < child node id.
However, I have a intuition that there might be some situation in which this check will fail and There will be some loops created by the user.
Is there a simple solution to change the parent of a node while making sure that there is no situation of loop formation.
Upvotes: 0
Views: 43