How to use the get_path()
method when working with disconnected subgraphs in a network
#29
-
Hi @jcmgray, I am currently trying to use the def get_community_edge_betweenness_tree(self):
"""
Purpose
-------
Use the community edge betweenness method to find the network contraction tree.
"""
# Create igraph object to use community betweenness
inputs, output, indexSizes = self.network.get_inputs_output_size_dict()
# Loaded inputs/outputs
tensorNetworkGraph = cotengra.path_igraph.oe_to_igraph(
inputs, output, indexSizes
)
# Created igraph tensor network
dendrogram = tensorNetworkGraph.community_edge_betweenness()
merges = dendrogram.merges
self.tree = cotengra.core.ContractionTree.from_path(
inputs, output, indexSizes, ssa_path=merges
)
# Setting this is crucial, it outputs the same path as igraph, but as a quimb object
self.tree.set_surface_order_from_path(merges)
self.contraction_path = self.tree.get_path(order="surface_order") The only problem I found as of right now is that when I have a network that contains 2 or more disconnected "subgraphs", then I end up getting an error when calling the
In this case, I have a network that contains 60 tensors and 4 of the tensors form a small disconnected subgraph of their own, leaving the other 56 tensors as one big subgraph of the whole network. After some analysis, I think that I have found the variable that causes this problem, it seems to be I was wondering if there was a way to work around this issue or if there is already a method that can deal with those disconnected subgraphs? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes I'm guessing the |
Beta Was this translation helpful? Give feedback.
I've added this and some related functionality here: 6b5c173 and 85f15ce. Now by default it will autocomplete e.g. disconnected subgraphs but issue a warning that the path was incomplete. If instead you explicitly call
.from_path(..., autocomplete=True)
(as in path_igraph.py) it will do it without complaining.