Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some AbstractNamedGraph functionalities #8

Merged
merged 4 commits into from
Nov 1, 2022
Merged

Add some AbstractNamedGraph functionalities #8

merged 4 commits into from
Nov 1, 2022

Conversation

leburgel
Copy link
Contributor

@leburgel leburgel commented Oct 3, 2022

Some convenience AbstractNamedGraph functionalities that I ended up using quite often, so I though it could make sense to add them here. A summary of the (potential) additions:

  • A function rename_vertices which allows renaming the vertices of an AbstractNamedGraph or AbstractNamedEdge given a Function or Dictionary name map. It is basically the same as the one in https://github.com/mtfishman/ITensorNetworks.jl/blob/main/examples/peps/utils.jl, with some minor adjustments to make it work for all currently existing AbstractNamedGraph subtypes. In particular, it seemed to make sense to allow renaming to change the vertex type for the case of NamedGraph.
  • Constructors for all currently existing AbstractNamedGraph subtypes which just take a list of vertices, similar to how Graphs.Graph(::Integer) returns a graph with a given number of vertices and no edges.
  • Equality for AbstractNamedGraphs, useful for checking if the underlying graph of two instances of a given data structure is the same.

src/abstractnamededge.jl Outdated Show resolved Hide resolved
Introduce internal `set_vertices` for every `AbstractNamedGraph` and
`AbstractNamedEdge` used in `rename_vertices` for abstract types
@leburgel
Copy link
Contributor Author

leburgel commented Nov 1, 2022

As per the suggestions above, I switched to a core map-like interface for rename_vertices for AbstractNamedEdge and AbstractNamedGraph, with a Dictionary name map as a special case. These now rely on an internal set_vertices routine defined for each concrete subtype.

src/abstractnamededge.jl Outdated Show resolved Hide resolved
@mtfishman
Copy link
Member

Looks great, thanks a lot! Also thanks for adding all those tests, these packages have been undertested...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants