Kemsekov / GraphSharp

GraphSharp is a tool to study and use knowledge of graph theory in C#!
MIT License
38 stars 5 forks source link

Make NodesFactory-IGraph safer. #11

Closed Kemsekov closed 2 years ago

Kemsekov commented 2 years ago

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?

Kemsekov commented 2 years ago

I am changed Graph constructor to use NodesFactory.

Kemsekov commented 2 years ago

Done.