New similar_graph interface for AbstractDataGraph; misc bug fixes. #94
New similar_graph interface for AbstractDataGraph; misc bug fixes. #94mtfishman merged 36 commits intoITensor:mainfrom
similar_graph interface for AbstractDataGraph; misc bug fixes. #94Conversation
|
@jack-dunham I have to admit I've gotten a bit lost here in terms of how the functionality in this PR will be used. Where is |
|
To be specific, if we take the analogy with similar for arrays seriously, I think it would leave us with: similar_graph(g::AbstractDataGraph) # similar(a::AbstractArray)
similar_graph(g::AbstractDataGraph, vertices, edges) # similar(a::AbstractArray, axes)
similar_graph(g::AbstractDataGraph, vertex_data_type::Type, edge_data_type::Type) # similar(a::AbstractArray, T::Type)
similar_graph(g::AbstractDataGraph, vertex_data_type::Type, edge_data_type::Type, vertices, edges) # similar(a::AbstractArray, T::Type, axes)
# Type version
similar_graph(graph_type::Type{<:AbstractDataGraph}, vertices, edges) # similar(array_type::Type{<:AbstractArray}, axes)Underlying graph feels a little "low level" to expose to this kind of interface (maybe it is needed but it would be nice to think through that). I think one application of that is to make a similar graph that changes directedness, i.e. specifies it should be directed or undirected, but maybe that could be handled in another way (like with a trait input like Also, how does this interface handle data graphs that only have edge or vertex data? I think that would be a pretty big source of ambiguity so is worth considering here. That would be a compelling reason to base things around trait wrappers like |
|
I agree with everything you are saying. For some reason I had it in my head that you could do: similar(Matrix, Float64, (2, 2))but this is not the case. One should do similar(Matrix{Float64}, (2,2))Instead we can have (in future): similar_graph_type(::Type{<:AbstractDataGraph}, VD::Type, ED::Type, G::Type)which returns a similar_graph(::Type{<:AbstractDataGraph}, vertices, edges)the rest of the type domain methods can be removed (with the prospect of later adding As for underlying graphs we can just have the methods: similar_graph(::AbstractDataGraph, underlying_graph::AbstractGraph)
similar_graph(::Type{<:AbstractDataGraph}, underlying_graph::AbstractGraph)and avoid the combinatorics explosion of combing this with all the other possible arguments. I do appreciate your point regarding underlying graph being too "low level", but the existence of such a graph is explicitly part of the Thanks for the comments. |
Currently, subtypes that do not have e.g. edge data have edge data type struct GraphWithoutEdgeData{V, VD} <: AbstractDataGraph{V, VD, Nothing} endand: similar_graph(graph_without_edge_data, VD, Nothing) or for the edge data case: similar_graph(graph_without_vertex_data, Nothing, ED) Of course given similar_graph(graph::GraphWithoutEdgeData, VD::Type) = similar_graph(graph, VD, Nothing)etc. which could be done abstractly using |
04a2fae to
a531d78
Compare
|
To record conversations had on slack, the implemented similar_graph(g::AbstractDataGraph) # similar(a::AbstractArray)
similar_graph(g::AbstractDataGraph, vertices) # similar(a::AbstractArray, axes)
similar_graph(g::AbstractDataGraph, data_type::Type) # similar(a::AbstractArray, T::Type, axes)
similar_graph(g::AbstractDataGraph, data_type::Type, vertices) # similar(a::AbstractArray, T::Type)
similar_graph(g::AbstractDataGraph, vertex_data_type::Type, edge_data_type::Type) # similar(a::AbstractArray, T::Type)
similar_graph(g::AbstractDataGraph, vertex_data_type::Type, edge_data_type::Type, vertices) # similar(a::AbstractArray, T::Type, axes)
# Type version (defined abstractly in `NamedGraphs`.)
similar_graph(graph_type::Type{<:AbstractDataGraph}, vertices) # similar(array_type::Type{<:AbstractArray}, axes)i.e. we have no methods taking the underlying graph as an argument. This is in anticipation of removing |
|
Looks like test failures are caused by recent changes to the shared test workflow, I'll investigate. |
for creating data-less subgraphs.
…ngs. The single data type defines both the vertex data type and the edge data type.
…rtitionedGraphs` ext.
This PR includes some bug fixes and a new
AbstractDataGraphspecific method for the functionsimilar_graphfrom theNamedGraphs.GraphsExtensionslibrary.similar_graphmethods that take underlying_graph as an input, and reconsider parts of the code where this is used.set_underlying_graphfunction