This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
i am not very fit in recursion. hope someone can help me. here's my prob: i traverse an xml-structure recursively to draw a conetree (3dimensional graph) from it, see picture. for each xml-node a point in a 3dimensional space is drawn. to calculate the radius of a circle of nodes, i need the radii of its subcircles. (otherwise the circles could overlap). i don't get how i can manage this in my recursion. i would have to traverse the xm-file backwards to start drawing the tree at the bottom, right? but recursion starts at the beginning of the xml-file, doesn't it?
basically my question is: how can i manage to know a variable of a recursion level below? hope my problem is clear.
Sorry I didn't take time to read your code closely, but here are two ways to look at recursion:
With the second structure each call to a child might return the graph that it's goind go draw for that child, then you fit the graph you're going to draw for the current node around that and return the new combination. Does taht kinda make sense?
Myself, I'd look for something already written! See if Grappa can draw what you need. It's pretty easy to make up a simle DOT file as input.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Jan 20, 2006
yip! that's exactly what i meant. thank you. but now i dont get where to set the child of the current point as the parent, so that each childelement becomes a childpoint of its parent point?! in the following code, children of a point should be shifted -10 in z-position relatively to their parent. but all points are in the same position... what's wrong with this code? seems like the points are not nested, but why?
ps: grappa is interesting, but i want to create a conetree in a a vrml-scene. at first sight it seems that grappa isn't suitable for this...
Joined: Jan 29, 2003
I can't quite visualize your output, but it sounds like you need to put the children in a little cloud by varying one or more of the coordinates. You'll also have to know how big each child is to decide how far to move for each one. So even if the root has only two children they may have to be very far apart because they have many children that take up a lot of x-y space. Or am I thinking too much like a 2-D tree?
Joined: Jan 20, 2006
right, that's why i need to draw the tree from upside down. later, i will have to add another variable "number of children" of each node. with this variable the radius of each "cloud /circle" of childnodes can be calculated.
but first, i want to get the shifting in z-pos working. it seems like my recursion does not work correct. it should nest the childnodes into their parentnodes, which it apparently does not, because when a node with relative z-pos 10 is _in_ another node, it has the relative position 10 to its parent. with the method from my first posting it works fine, but there i cannot add the variable "number of children" to calc the radius (x,y). that's why i turned it around to start from upside down, see my 3rd posting. but now it doesn't work anymore.
i think is has to do with setting the new child as parentnode. do i have to modify this part of the method when turning it around? [ March 08, 2006: Message edited by: gon to ]