@smellymumbler Hey, for sure. In fact, I can refer you directly to the source!
In our approach, we have three main classes for the Node Graph:
- IoGraph - handles node add/delete, link add/delete, and solving the graph.
- IoComponentBase - the base class for inheriting nodes that do particular things. There are a bunch of important functions in this class, but by far the most important is the SolveInstance. This handles what exactly the node does.
- IoInputSlot and IoOutputSlot - these classes handle what kind of data is passed to SolveInstance, and the level of DataAccess (i.e. Item, List, Tree).
So, to interact with the NodeGraph, you would create some custom nodes from IoComponentBase and then add them to the graph, along with some connections, and add some data at the exposed input slots. Here is an example from one of the tests:
Context* myContext = new Context();
//push data to data tree
IoDataTree tree0(myContext, someFloats);
//create graph object
//create the Mass Average component
SharedPtr<IoComponentBase> averager(new Maths_MassAverage(myContext));
//add the data tree input at component index 0, input slot index 0
g.SetInputIoDataTree(0, 0, tree0);
//solve using topological sorting
g.GetOutputIoDataTree(0, 0, outTree);
We use a topological sorting algorithm that orders that orders the nodes by their rank (i.e. how many edges away from being a root node). Then, you can loop through the nodes and call the Solve methods.