Tropashko nested sets and materialized path - great idea but how do I insert?

From: Robin Tucker <r.tucker_at_thermoteknix.com>
Date: Thu, 11 Sep 2003 11:15:38 +0100
Message-ID: <bjphtu$279$1$8302bc10_at_news.demon.co.uk>



I'm sure this has been answered many times before, unfortunately my news server only has the last 300 or so messages from this group.

I have implemented Tropashkos' nested sets and materialized path algorithms for my tree structure - I can see how I might insert a new node after the current right-most node, but I cannot see how to "insert_before(node)" or "insert_after(node)" or cut/paste parts of the hierarchy around. I guess the problem
here is I lack an understanding of binary fractions. For example, say the hierarchy
node .2.3 is represented by 83/64, is there a quick and easy way of bumping the node up one to 2.4? And then how can I also increment the node 2.3.2 for
example so it is now 2.4.2? I would like to do this with a single "Update", so I can
make a gap for the new node to be inserted. I know how to select the hierarchy
from a give node.

This would seem to me to be a real problem with this method which the adjacency list handles sweetly. Perhaps there is a discussion on these points somewhere? I would love a solution because without it I will just have to ditch the nested sets and materialized path implementation and head back over to the rather dodgy adjacency list.

Thanks for any info you can give me.

Robin Tucker Received on Thu Sep 11 2003 - 12:15:38 CEST

Original text of this message