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

Contraction tree to graph #53

Merged
merged 11 commits into from
Jan 25, 2023
Merged

Conversation

JoeyT1994
Copy link
Contributor

This PR adds functionality for converting a contraction sequence (outputted by contraction_sequence(tn)) to a graph.
Testing is also included.

It is possible the output (which is just a NamedGraph) should be defined as it's own type so that methods like leaf_node can be assigned explicitly to it.

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

Thanks @JoeyT1994! It's a very good question you bring up about what the type should be.

I would prefer to not introduce a new type, and I'm hoping with good generic code and good function names we can make it clear when a function should be used on a tree graph (i.e. a NamedGraph that happens to have a tree structure) and additionally a tree graph representing a contraction sequence, with internal vertex names that store information about the leaves of the subgraphs. For example, for functions that only make sense for contraction tree graphs or make use of that vertex naming convention, we could use function names of the form contraction_tree_*.

@mtfishman
Copy link
Member

Finally, even though we have that vertex naming convention, it may be better to try to write code that is written for generic graphs and/or tree graphs that don't have any special vertex naming convention, even if the code is a bit slower in principle. That way we build out useful tools for working with general tree graphs, and we can always make specialized functions that make use of the vertex naming convention for cases where it actually makes a performance difference.

@codecov-commenter
Copy link

codecov-commenter commented Jan 25, 2023

Codecov Report

Merging #53 (2aa8a56) into main (3d7342b) will decrease coverage by 0.10%.
The diff coverage is 71.92%.

@@            Coverage Diff             @@
##             main      #53      +/-   ##
==========================================
- Coverage   76.47%   76.38%   -0.10%     
==========================================
  Files          52       54       +2     
  Lines        2725     2782      +57     
==========================================
+ Hits         2084     2125      +41     
- Misses        641      657      +16     
Impacted Files Coverage Δ
src/ITensorNetworks.jl 77.77% <ø> (ø)
src/Graphs/abstractgraph.jl 30.00% <30.00%> (ø)
src/contraction_tree_to_graph.jl 94.59% <94.59%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@mtfishman
Copy link
Member

Looks good, thanks again!

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