简体   繁体   English

统一递归树Java的实现

[英]Implementation of Uniform Recursive Tree Java

I was able to find implementations for so many Trees such as, 我能够找到许多树的实现,例如,

http://sujitpal.blogspot.com/2006/05/java-data-structure-generic-tree.html http://sujitpal.blogspot.com/2006/05/java-data-structure-generic-tree.html

and now I am in search for implementation of Uniform Recursive Tree in Java. 现在我正在寻找Java中统一递归树的实现。 This paper explains details on Uniform Recursive Tree. 本文介绍了统一递归树的详细信息。 http://www.sciencedirect.com/science/article/pii/S0022247X05004191 http://www.sciencedirect.com/science/article/pii/S0022247X05004191

Thanks in advance for your help. 在此先感谢您的帮助。

This isn't that hard to implement, actually. 实际上,这并不难实现。 You basically start with an n-ary tree and all you have to do is figure out how to add a node as a child to one of the existing nodes in the tree. 您基本上是从n元树开始的,您所要做的就是弄清楚如何将一个节点作为子节点添加到树中的现有节点之一。

For a tree with k nodes, a new node k + 1 can become a child of any one of the previous k nodes (ie, any of the nodes in the set {1, 2, ..., k} ). 对于具有k节点的树,新节点k + 1可以成为先前k节点中的任何一个的子节点(即,集合{1, 2, ..., k}中的任何节点)。

What you would need is a list of all nodes that currently exist in the tree. 您需要的是树中当前存在的所有节点的列表。 I would maintain this is a separate, internal structure within the Tree data-structure. 我将保持这是Tree数据结构中一个独立的内部结构。 Then you will have to figure out how to select one of the nodes of the tree. 然后,您将必须弄清楚如何选择树的节点之一。 This is done by a probability function. 这是通过概率函数完成的。 I find this part to be a little unclear and that's mostly because I've forgotten a lot of my probability stuff (and I hated probability in school). 我发现这部分内容尚不清楚,这主要是因为我忘记了很多概率材料(而且我讨厌在学校学习概率)。 But the paper does explain how you can compute the probabilities. 但是本文确实解释了如何计算概率。 Essentially you have a series of probability mass functions. 本质上,您具有一系列概率质量函数。 So if you have a node 1 , and then a node 2 , node 2 will be attached to node 1 (because there is only one node for 2 to be attached to). 因此,如果您有一个节点1 ,然后有一个节点2 ,则节点2将附加到节点1 (因为只有一个节点可将2附加到该节点)。 A node 3 will be attached to node 1 with a probability of p(2, 1) or to node 2 with a probability of p(2, 2) . 节点3将以概率p(2, 1)附加到节点1或节点2以概率p(2, 2)附加到节点p(2, 2) What you have to make sure though, is that: 不过,您必须确定的是:

p(k, i) >= 0

and: 和:

sigma(p(k, i)) from i = 1 to k equals 1

A naive implementation would be to simply select one of the nodes randomly out of a list of existing nodes. 天真的实现方式是从现有节点列表中随机选择一个节点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM