If you have a function which returns true if a node is a descendant of another node as in boolean is_descendant (NODE a, NODE b); // returns true if node b is a descendant of node a then do not allow the insertion of a child to a node if that node is a descendant of the child. Dave Diaz > -----Original Message----- > From: Tracy Pierce [SMTP:[log in to unmask]] > Sent: 26 December 2001 19:04 > To: [log in to unmask] > Subject: [HP3000-L] TREES: anti-loop algorithm? > > I have a set of activities which sometimes include other activities; this is > recursive, the result resembles a tree structure, similar to a directory > tree. Until now I've quite simply disallowed 'multiple parents', but > largely because my brain's too feeble to see a cleaner loop-avoidance > mechanism. > > (Clear as mud? Here I have A includes B & D, B includes C, E includes F, > all just lovely. This works nicely even in a physical sense, and looks like > a tree.) > > ActA > |-ActB > |-ActC > |-ActD > ActE > |-ActF > > Now I need to add ActF to ActC, basically meaning I want to allow leaf F > appear on multiple trees. This is ok, but the procedure of adding ActF to > ActC must include enough exhaustive checking to ensure that I disallow > creation of loops, such as that which would occur if I were to add ActA to > ActC. > > Can anyone here on good old HP3000-L point me in the direction of the > perfect solution? (I just KNOW there are papers out there, so even a good > Google key would be a great pointer!) > > TIA > > Tracy Pierce > > * To join/leave the list, search archives, change list settings, * > * etc., please visit http://raven.utc.edu/archives/hp3000-l.html * * To join/leave the list, search archives, change list settings, * * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *