Skip to content

Conversation

@jack-dunham
Copy link
Contributor

@jack-dunham jack-dunham commented Nov 3, 2025

This PR renames some types and functions in the PartitionedGraphs library for clarity. Specifically:

  • PartitionsGraphView -> QuotientGraph.
  • PartitionVertex -> SuperVertex.
  • PartitionEdge -> SuperEdge.

The associated functions pertaining to these types have also been renamed accordingly. I have also attempted to rename local variables to reflect this change.

Tests have been updated, and by some miracle, all passed first time.

@jack-dunham
Copy link
Contributor Author

Considering this is technically a breaking change I've opted to increment the minor version number.

@mtfishman
Copy link
Member

Thanks @jack-dunham, I think these names are clearer. @JoeyT1994 let us know what you think of these changes, I think we've discussed these name changes.

@jack-dunham when you make breaking changes you need to bump the subdirectory Project.toml compat entries accordingly (i.e. docs/Project.toml, examples/Project.toml, test/Project.toml). It's a bit annoying, ideally we wouldn't have to specify the compat entries of the package itself in those subdirectories but we have to right now because of limitations of CompatHelper.

@JoeyT1994
Copy link
Collaborator

Yeah I like these name changes -> they are more intuitive and quotient graph is in-line with the definition from the graph-theory community.

@mtfishman
Copy link
Member

@jack-dunham @JoeyT1994 I'll merge this so we can start using it in ITensorNetworksNext.jl. ITensorNetworks.jl and TensorNetworkQuantumSimulator.jl will need to be upgraded but that should be pretty easy since it is just a name change.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

Your PR no longer requires formatting changes. Thank you for your contribution!

@jack-dunham
Copy link
Contributor Author

jack-dunham commented Nov 10, 2025

To summarize:

# If you want a non-trivial partitioning, then overload the following function:
partitioned_vertices(g::MyGraphType)

# For fast quotient graph construction and fast `has_edge` at the quotient_graph level:
quotient_graph(g::MyGraphType)
# You should also define the `quotient_graph_type` via:
quotient_graph_type(g::MyGraphType)
# if this is differs from the default give by:
quotient_graph_type(g::AbstractGraph{V}) where {V} = NamedGraph{V}

# For a fast vertex to quotient-vertex map then:
find_quotient_vertex(g::MyGraphType, vertex)
# ...which automatically gives a fast edge to quotient-edge map via:
find_quotient_edge(g, edge) # no need to overload this.

# For fast finding of edge partitions: 
partitioned_edges(g::MyGraphType)

If any of the above properties are desirable for MyGraphType, then store the data in a field and overload the associated function to get that field, e.g.

find_quotient_vertex(g::MyGraphType, vertex) = g.inverse_vertex_map[vertex]

where we have chosen to store the map in the field inverse_vertex_map of the MyGraphType type. Doing this is not essential as everything can and will be derived from partitioned_vertices as a fallback.

@mtfishman
Copy link
Member

Thanks for the summary, looks like a good interface.

What about the names quotient_vertex/quotient_edge instead of find_quotient_vertex/find_quotient_edge? find has a particular conventional meaning in Base of functions that search for values and return the indices of those values, I worry those functions don't quite match up with that convention.

- `add_vertex!` not takes the `SuperVertex` argument before the regular
vertex argument.
- Updated tests to reflect the interface change.
@mtfishman
Copy link
Member

@jack-dunham looks like the PR needs formatting.

@mtfishman mtfishman marked this pull request as ready for review November 11, 2025 21:44
@mtfishman
Copy link
Member

This looks good to me, thanks for sticking with all the comments. Is this ready on your end? If so I'll merge and register.

@jack-dunham
Copy link
Contributor Author

jack-dunham commented Nov 11, 2025

This looks good to me, thanks for sticking with all the comments. Is this ready on your end? If so I'll merge and register.

I think I want to spend another hour to do one final pass over the code and write some more tests to check the extra stuff added. Ill let you know when I'm done on my end.

Jack Dunham and others added 2 commits November 12, 2025 10:27
…type parameter of its underlying graph

Co-authored-by: Matt Fishman <mtfishman@users.noreply.github.com>
@mtfishman
Copy link
Member

@jack-dunham looks good from my end, ready to merge?

@mtfishman mtfishman merged commit d09d910 into ITensor:main Nov 12, 2025
12 of 13 checks passed
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.

3 participants