Faster loop enumeration#177
Conversation
Co-authored-by: Matt Fishman <mtfishman@users.noreply.github.com>
Co-authored-by: Matt Fishman <mtfishman@users.noreply.github.com>
Co-authored-by: Matt Fishman <mtfishman@users.noreply.github.com>
Co-authored-by: Matt Fishman <mtfishman@users.noreply.github.com>
Co-authored-by: Matt Fishman <mtfishman@users.noreply.github.com>
…aphs.jl into mf/partitionsgraphview
PartitionsGraphView update
for more information, see https://pre-commit.ci
|
Your PR no longer requires formatting changes. Thank you for your contribution! |
| mutable struct NoLeafSubgraphSearch | ||
| # Endpoints of each edge, as integer vertex indices (indexed by edge index). | ||
| const edge_src::Vector{Int} | ||
| const edge_dst::Vector{Int} | ||
| # Line-graph adjacency: `edge_neighbours[i]` lists the edges sharing a vertex with edge `i`. | ||
| const edge_neighbours::Vector{Vector{Int}} | ||
| const max_edges::Int | ||
| # Induced degree of each vertex within the current edge set. | ||
| const vertex_degree::Vector{Int} | ||
| # Number of vertices whose induced degree is exactly 1 (i.e. leaves of the current set). | ||
| num_leaves::Int | ||
| # `marked[u]` is true while edge `u` is in the current set or already queued for it. | ||
| const marked::Vector{Bool} | ||
| # The current edge set, used as a stack. | ||
| const current_edges::Vector{Int} | ||
| # Completed leaf-free edge sets (each a vector of edge indices). | ||
| const results::Vector{Vector{Int}} | ||
| end |
There was a problem hiding this comment.
Since most of the fields are set to const anyway, it might be better to make the type not mutable and then make the field num_leaves::Base.RefValue{Int}. Then you can update it with search.num_leaves[] += 1 and access it with search.num_leaves[].
| name = "NamedGraphs" | ||
| uuid = "678767b0-92e7-4007-89e4-4527a8725b19" | ||
| version = "0.12.2" | ||
| version = "0.12.3" |
There was a problem hiding this comment.
Since we are deleting unique_simplecycles_limited_length I think we'll need to mark this as breaking, i.e. v0.13. I guess the idea is that function is just not very useful so we may as well not support it any more?
There was a problem hiding this comment.
Yeah it was only being used inside the previous version of edgeinduced_subgraphs_no_leaves so seems no point in supporting it. Will bump it
|
@JoeyT1994 what do you think of the name |
|
@mtfishman Yeah that's a slightly simpler name, I'll change to that |
## Summary Widen the `NamedGraphs` compat to allow v0.13 (ITensor/NamedGraphs.jl#177). That release rewrites the leaf-free edge-induced subgraph enumeration and drops the old internal cycle-enumeration helpers, none of which DataGraphs uses, so it stays compatible with both v0.12 and v0.13.
## Summary Widen the `NamedGraphs` compat to allow v0.13 (ITensor/NamedGraphs.jl#177). That release rewrites the leaf-free edge-induced subgraph enumeration and drops the old internal cycle-enumeration helpers, none of which ITensorNetworks uses, so it stays compatible with both v0.12 and v0.13.
## Summary Widen the `NamedGraphs` compat to allow v0.13 (ITensor/NamedGraphs.jl#177). That release rewrites the leaf-free edge-induced subgraph enumeration and drops the old internal cycle-enumeration helpers, none of which ITensorNetworksNext uses, so it stays compatible with both v0.12 and v0.13.
This PR replaces the
edgeinduced_subgraphs_no_leaves(g::AbstractGraph, max_edges::Integer)function with a much faster and fully correct implementation.The function takes a graph
gand enumerates all connected, edge induced subgraphs with up tomax_edgeswhich contain no leaf (degree 1) vertices. This induced graphs are the basis of a cluster expansion.The function is now completely correct (the previous version missed out subgraphs with bridges) and much much faster (many hundreds of times on large graphs).
Tests are updated to reflect this and check the expansion.