This is what I currently use to get all child nodes starting from one specific point (being root or not)... again simplified :Root: First = 1; Last = 5; Next = ; Previous = ; 1: First = 11; Last = 15; Next = 2; Previous = ; 2: First = 21; Last = 25; Next = 3; Previous = 1; ... 554: First = ; Last = ; Next = 555 ; Previous = 553; 555: First = ; Last = ; Next = ; Previous = 554;
Output is something similar to:push(@Children,$root->child_nodes); # could be push(@Children,$start_n +ode_id); too, any starting point... while(@Children) { $node = shift @Children; print $node,"->"; my $Node = Node->new($node); my $next = $Node->first; while ($next) { print $next,","; my $Child = Node->new($next); push(@Children,$next); $next = $Child->next(); } print "\n"; }
I'm not building a tree perse, the order in which I get child nodes is not important. I dont need to store all child node data, just the actual node IDs. There could be alot of child nodes, resources could get quite limited.1->11,12,13,14,15, 2->21,25, 3->31,35, 4->41,45, 5->51,55, 11->111,112,113,114,115 12-> 13-> 14-> 15-> ...
In reply to Growing exotic trees by Beatnik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |