algorithmic modeling for Rhino
Hey all,
I am working on a leaf venation script in python, in which a vein grows by adding nodes off of existing nodes.
I am trying to convert the script to store the nodes in a datatree (which has the same structure of the vein - i.e. each node along the length of a branch in the vein is a child of the node before it in the datatree, and where the vein branches, a datatree node has two children.
So, I need to iterate over all existing nodes, and I need to keep track of each node's path within the NodeTree in order to add the child node in the right place.
This is the structure of the loop I came up with:
NodeTree initially contains the roots, so if you have two roots, they are at {0,0}, and {0,1}
for i in range(0, NodeTree.BranchCount):
--CurrPath = NodeTree.Path(i)
--NodeList = NodeTree.Branch(CurrPath)
--for Node in NodeList:
----//make new node
----//find first unoccupied child of CurrPath (if there is already a child, then we are
forming a second branch from our current location)
----//place new node in that location in the datatree
The problem is that now my tree grows in a depth-first manner, so the second tree will not begin growing until the first tree has stopped growing.
Is there a better way for me to traverse the NodeTree? One that would give me breadth-first growth, and make the trees grow simultaneously?
Thanks,
Harrison
I think this is how i want to travel the tree:
Tags:
Hallo Harrison,
Don't know if this helps but SpiderWeb provides a .NET library (don't know if you can use it) for graphs, including BFS / DFS.
Richard
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by