New interface for GraphsExtensions.similar_graph; misc bug fixes.#147
Open
jack-dunham wants to merge 9 commits intoITensor:mainfrom
Open
New interface for GraphsExtensions.similar_graph; misc bug fixes.#147jack-dunham wants to merge 9 commits intoITensor:mainfrom
GraphsExtensions.similar_graph; misc bug fixes.#147jack-dunham wants to merge 9 commits intoITensor:mainfrom
Conversation
Was assuming a specific constructor previously.
Member
Is that supposed to be: empty_graph(T::Type{<:AbstractGraph})? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 overhauls the way the
GraphsExtensions.similar_graphfunction behaves, and includes some minor bug fixes and refactors.New
similar_graphinterfaceEssentially, the base case is now the three argument method, where one provides both
verticesandedges. This defaults to constructing a concreteNamedGraphorNamedDiGraphdepending on theIsDirectedtrait of the input graph.If edges are not provided, then the function attempts to construct a similar graph to the input graph, but with the provided vertices and no edges. If no vertices or edges are provided, then the output graph will be a similar empty graph. For a given subtype of
AbstractNamedGraph, one should overload the three argument method only (if a different return type is desired).Type domain
If instead a graph type is provided as the first argument to
similar_graph, then the constructor is called by default:Note, unlike the case where a graph value is provided, the one and two argument methods are not defined in terms of the three argument method. This is to accommodate cases where a given
AbstractGraphmay have fixed edges, say (a notable example would be a tree graph). In that case, it is assumes there exists a constructorT(vertices). As the methodmay or may not return an edgeless graph, depending on the definition of the constructor, there exists the function
that attempts to explicitly a construct an edgeless graph, thus throwing an error when this is not possible. Likewise, there exists a function
for explicitly constructing a graph of type
Twith no vertices or edges.If your graph type
MyGraphhas freedom over vertices and edges, all three type-based method can be overloaded simultaneously using the followings signature: