Traversing Graph

   2145   4   0
User Avatar
Member
126 posts
Joined: Aug. 2010
Offline
How do you best traverse a forking polyline graph (a tree)?

As I understand, VEX does not support recursion, and in Python there's no easy way to get connectivity information!

EDIT:
I tried promoting the neighbors to an point attribute array via vex. But now it turns out that python (hou) can't read point attribute arrays?
Edited by aeaeaeae - March 27, 2017 10:38:52
User Avatar
Member
2529 posts
Joined: June 2008
Offline
It is very easy to get the connectivity information in Python. Just use node.inputs().
Edited by Enivob - March 27, 2017 13:44:01

Attachments:
python_inputs.gif (158.1 KB)

Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
7710 posts
Joined: July 2005
Online
As far as I recall, reading array attributes from python should just work using the usual methods to read attribute values.

Having said that, I would consider doing it all in VEX. You can put the Attribute Wrangle in Detail mode and then loop to your hearts content. Recursion is not necessary for graph traversals, there are plenty of ways to do things iteratively using array variables as stacks.
User Avatar
Member
126 posts
Joined: Aug. 2010
Offline
thanks guys.

@Enivob: Connectivity in terms of SOP geometry. For example There's no direct way via python to find the connected neighbors of a point, although, as a work around you can store them an point attribute array via VEX first, and read that.

@edward: right, VEX and non-recursion algorithms are probably the best, I'll try out some of these [stackoverflow.com]
Edited by aeaeaeae - March 28, 2017 07:51:20
User Avatar
Member
7710 posts
Joined: July 2005
Online
smuseus
I'll try out some of these [stackoverflow.com]

Ack, from the best answer on that stack overflow link, do NOT do take_first()/prepend() (in any language). Just use the VEX pop()/push() functions, which do “remove last” and “append to end” respectively.
Edited by edward - March 29, 2017 00:35:19
  • Quick Links