QuikGraph
QuikGraph copied to clipboard
Add flag or config object to algorithm constructors to be able to specify how algorithm objects are initialized
As described in #13 the instantiation of all shortest path algorithms include adding all vertices to the distance and vertex color dictionaries.
There are two possible issues with this:
- In case of graphs with many vertices the initial looping over all the vertices in the graph could become rather expensive.
- When using the Distances dictionary it might be preferable if no distance is returned for an inaccessible vertex instead of a Double since that a) can lead to unnecessary extra logic on the callers side to make sure a vertex is accessible and b) can result in unnecessary looping in case the caller wants to do something with all the key-value pairs in the dictionary.
To be able to avoid this it should be possible to influence whether the dictionaries are populated on instantiation or not. This can be done either by adding a flag directly to the constructor or by using a config object with the flag as a property.
Using a config object instead of a single flag would make it easier for us to add more flags in the future if needed without breaking backwards compatibility, so I would propose we did it that way.
Having a "config" structure on construction would be great for evolution indeed. We should think about having multiple layer of config structure since some algorithm can share common setup.