AbstractDataGraph interface redesign
#56
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a change to the
DataGraphsinterface. The following functions must now be overloaded for a graph to behave like a data graph:The functions
getindex,setindex!get!etc are all defined in terms of those. It is a bit more verbose than just having a functionvertex_dataetc that returns a mutable dictionary, but I think it is ultimately more generic. The return value ofvertex_dataetc is now constructed on the fly, so doingsetindex!(vertex_data(g), val, vertex)will not modify the underlying graph.To rename vertices, one must also overload:
The benefit of this change is that one no longer require the data on the vertices and edges to be stored as a mutable field; it can be generated on the fly. This then results in constant behavior when defining views of vertex/edge data. One can still use a mutable dictionary to store the data for a given concrete
AbstractDataGraphsubtype.Other Changes
AbstractDataGraphnow subtypesAbstractNamedGraph. This greatly reduces required method overloads.To do
DataGraphallows anAbstractSimpleGraphas its underlying graph. This will result in mismatched vertices between the underlying graph vertices and the vertex data dictionary if one removes or adds a vertex from the data graph.VertexDataViewetc