Graph Layout Plugin - Part 1

General / 26 September 2019

In typical fashion, instead of finishing anything, I start something new. A plugin to organize Designer graphs!


This has proven to be a very interesting and challenging problem. A lot harder than I initially thought, but I have managed to reach a point where I can reliably sort a simple non recursive chain into my preferred layout style. 


The current implementation involves traversing down the chain building a coordinate system, then going through the chain again actually placing them according to the coordinates. The goal was to build these lane structures that respect the dimension of other parts of the network, so when finding a branch node (such as a blend), I step down each branch and return with its dimensions. This doesnt sound too bad, except how much to offset the nodes up and down also depends on which input slot the entire chain belongs in to begin with! It took some late nights and what was left of my balding hair, but I have a working solution now!


Networks that feed back into itself are a whole other beast, but I have made some progress here. There is a concept of a queue, where a split node (node with multiple outputs) will only position itself if all of its parents positions are known. If it cant successfully position itself, then it gets placed back into the queue, otherwise the whole process above repeats, building a brand new chain network. Theres are issues with this that I still need to work through, but its working well enough to show at least. So if there are any wizards reading this, tell me the magic! 


None the less, it has been a great exercise for me and I am learning a lot. In fact, the biggest challenge so far has been trying to work out exactly how I want the layout to behave and what that rule set is mathematically! Perhaps I can be a little better at blogging my process going forward too!


Thanks for reading!