Received: from bjke.com (firewall-user@ganymede.bjke.com [144.210.8.38]) by hub.org (8.9.1/8.9.1) with ESMTP id LAA20275 for ; Thu, 14 Jan 1999 11:17:19 -0500 (EST) (envelope-from djackson@cpsgroup.com) Received: by bjke.com; id KAA28614; Thu, 14 Jan 1999 10:17:15 -0600 (CST) Received: from cpsmail.cpsgroup.com(144.210.12.11) by gauntlet.bjke.com via smap (4.1) id xmaa27805; Thu, 14 Jan 99 10:16:27 -0600 Received: by cpsmail with Internet Mail Service (5.0.1458.49) id ; Thu, 14 Jan 1999 10:18:50 -0600 Message-ID: From: "Jackson, DeJuan" To: Neil Burrows Cc: PGSQL SQL Subject: RE: [SQL] A path through a tree Date: Thu, 14 Jan 1999 10:18:48 -0600 X-Priority: 3 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1458.49) Content-Type: text/plain > > If you want to use this for a message board I'd suggest inserting a > > dummy head that gets excluded from display in your app. instead of > > trying to have multiple heads. > > > > Let me know if you figure out an easy way to display > treading, haven't > > tried it myself. > > Eek! Caught! :) > > Thanks again, > > Regards, > > Neil Burrows Well, last night I thought it over and a Good(tm) way to display threading, hit me. If you don't ever delete a node, but just it's data you can use the l and r information recursively to display. function display(nodeList[][], currentNode, depth) { printf("%s|_%s\n", spaces(depth*2), nodeList[currentNode]['title']); numChildren = (nodeList[currentNode]['r'] - nodeList[currentNode]['l'] - 1)/2; for(numNodes=0;numNodes < numChildren; numNodes += display(nodeList, currentNode+numNodes+1, depth+1)) ; numNodes++; return numNodes; } I hope my psudo-code is decipherable. Looking at the tree from the previous message: l| r|data --+--+---- 1|12|head 2| 7|c1 3| 4|c11 5| 6|c12 8| 9|c2 10|11|c3 (6 rows) And using the information in the above function we get: |_head |_c1 |_c11 |_c12 |_c2 |_c3 Collapsing and expanding branches could simply be an array of booleans that's checked at currentNode where true display current node with a plus (link for html to expand) then return numChildren+1 otherwise do the loop. Just thought everybody might like to see this. -DEJ BTW if you want more examples of this data-layout of trees I can send in the URL's where I found it.