Graph Layout Plugin - Part 2

Work In Progress / 26 October 2019

In the last part, I had managed to get this project to a point where it could handle simple graphs pretty well and was working on solving recursive chains that split and branch back into each other. I was finding it very tough!

I showed the plugin to my tech director and he gave me some really good feedback, mostly related to how to approach the problem and general programming guidelines. Simply put, I had made the code so unwieldy and difficult to use that I could not hold all of it in my head or even debug properly. He set me the challenge of limiting all my functions to ~15 lines of code and with only 2-3 inputs; It really helped, thanks Christian!


So, I've rewritten the whole thing from scratch...


After spending some time trying to use it properly, I found the assumption of organizing an entire chain based on a single selected root node incredibly destructive. A lot of the time, I only wanted to quickly layout a small portion of the graph and leave other parts intact. So that's the first thing I fixed, it now works on your selection. I also hated clicking an icon, so it's now hot-keyed and supports a proper single undo. Previously it would undo one node at a time, ugh


This made working across multiple chains easy to implement, and can now handle multiple root nodes. In addition to this, placement now tries to find the longest horizontal in an attempt to produce the clearest results.


This means you can selectively manipulate node placement if you want too!


The biggest change however was with branching nodes (multiple inputs) and split nodes (multiple outputs). Previously I was recursively solving from the root (right to left), solving each branch as I got to it. Now however, I solve from the end to the chain up (left to right) and in an ordered fashion, which actually removed the need for recursion entirely and made node placement way easier.

So now chains originating from a split node are much more robust.


Its still being done in two passes like before, but now I only need to keep track of which split nodes have already been considered and if they need to be updated due to an offset.


Everything in the images so far are actually only solving along the x axis, I haven't got around to re-implementing the y offset yet, so that will be the next step. But I'm feeling happier with the development and think the algorithm is working much better now. The results in the gif below might look messy still (since its missing the y offset) but the x axis is solving correctly even for fairly complicated networks.


Thanks for reading!