Jump to content
  • Advertisement
Sign in to follow this  
Roof Top Pew Wee

Finding similar subtree structures.

This topic is 4776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Let's say I have some arbitrary tree of varying degree. If a particular node is selected, it's the root of some subtree. I'm interested in looking through the rest of the whole tree to find any subtrees of similar structure. That is, if the selected node were to be a leaf, the method would return an array of all nodes that are leafs. Again, the content of the nodes is not important; only the structure of the subtree that a particular node is the root of. My first solution is to create a new tree of identical structure of the subtree underneath the selected node. Then, traverse the whole tree, comparing the subtree created by every node by marking that node, then moving through the separate subtree to the tree created by the node. However, this is extremely inefficient considering the amount of repeated traversing. Any ideas on how to make this cleaner/more efficient? --Vic--

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!