Currently your Graph accepts only nodes that going in the same order as their Id. In the same time each node must contain Children-edges that are from the same set of nodes. This is bad. It means users can add to Graph whatever they want as nodes, which can be invalid set of nodes. In the same time you have NodesFactory, that capable of creating right set of nodes and edges. Maybe you somehow link them?
Accept in Graph constructor NodesFactory instead of nodes itself. Make checks that this factory nodes count > 0 and make copy of it's nodes to current instance of Graph.
But in the NodesFactory you have a bunch of methods to set and manipulate nodes whatever the way you want. This can also lead to errors. For example you can set WorkingGroup to any set of nodes, not strictly the same set from currently working NodesFactory instance. Honestly, I have no Idea how to fix it, but maybe add a bit more warnings in the description of methods of NodesFactory?
Currently your Graph accepts only nodes that going in the same order as their Id. In the same time each node must contain Children-edges that are from the same set of nodes. This is bad. It means users can add to Graph whatever they want as nodes, which can be invalid set of nodes. In the same time you have NodesFactory, that capable of creating right set of nodes and edges. Maybe you somehow link them?
Accept in Graph constructor NodesFactory instead of nodes itself. Make checks that this factory nodes count > 0 and make copy of it's nodes to current instance of Graph.
But in the NodesFactory you have a bunch of methods to set and manipulate nodes whatever the way you want. This can also lead to errors. For example you can set WorkingGroup to any set of nodes, not strictly the same set from currently working NodesFactory instance. Honestly, I have no Idea how to fix it, but maybe add a bit more warnings in the description of methods of NodesFactory?