[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Pairing up nodes into branchtree

JT

1/26/2015 3:30:00 PM

If i have full period permutation algorithm for x nodes, is there a way to make a node pairing algorithm from it without to much work?

I want to write all possible branch structures using x nodes and y branches.
But it seem i have to store how many nodes already connected to the graph.

Lets say i have a 16 node tree "valued array" and want 2 branches from each node i could connect 1->2 & 1->3 that made full branch for slot 1. And then 2->3 and 2->4 but then 3 already have 2 branches and have to be skipped.

Is there really no simpler way than storing the number of used branches with the three and check. It seem to create quite a highnumber of redundant check for heavily branched trees.
2 Answers

Erwin Moller

1/26/2015 4:20:00 PM

0

On 1/26/2015 4:29 PM, jonas.thornvall@gmail.com wrote:
> If i have full period permutation algorithm for x nodes, is there a way to make a node pairing algorithm from it without to much work?
>
> I want to write all possible branch structures using x nodes and y branches.
> But it seem i have to store how many nodes already connected to the graph.
>
> Lets say i have a 16 node tree "valued array" and want 2 branches from each node i could connect 1->2 & 1->3 that made full branch for slot 1. And then 2->3 and 2->4 but then 3 already have 2 branches and have to be skipped.
>
> Is there really no simpler way than storing the number of used branches with the three and check. It seem to create quite a highnumber of redundant check for heavily branched trees.
>

Could you post your desired "output"/structure for a low number of nodes
and leaves?
That might help (me) interpreting your question.

Regards,
Erwin Moller

--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens

Michael Haufe (\"TNO\")

1/26/2015 4:49:00 PM

0

On Monday, January 26, 2015 at 9:29:56 AM UTC-6, jonas.t...@gmail.com wrote:
> If i have full period permutation algorithm for x nodes, is there a way to make a node pairing algorithm from it without to much work?
>
> I want to write all possible branch structures using x nodes and y branches.
> But it seem i have to store how many nodes already connected to the graph.
>
> Lets say i have a 16 node tree "valued array" and want 2 branches from each node i could connect 1->2 & 1->3 that made full branch for slot 1. And then 2->3 and 2->4 but then 3 already have 2 branches and have to be skipped.
>
> Is there really no simpler way than storing the number of used branches with the three and check. It seem to create quite a highnumber of redundant check for heavily branched trees.

my 10 second thought: start from the bottom up. Use the algorithm from the first half of merge-sort, then as you walk up the tree, you build your permutations. When time permits, I'll sit down and do something concrete (if someone doesn't beat me to it)