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

Remove duplicate computation from block expansion #120

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions biobalm/_sd_algorithms/expand_source_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,14 @@ def expand_source_blocks(
for block, block_nodes in minimal_blocks:
block_sd = sd.component_subdiagram(list(block), node)

# The succession diagram "restricted" to the considered block should have
# the same (restricted) successor nodes.
assert len(
block_sd.node_successors(block_sd.root(), compute=True)
) == len(block_nodes)
# Instead of expanding the inner succession diagram "normally", we can
# copy the successors/stable motifs that we already know. This doesn't
# make too much of a difference unless the maximal trap space computation
# is complex, but that is sometimes true, especially for large networks.
for succ_id in block_nodes:
succ_motif = sd.edge_stable_motif(node, succ_id, reduced=True)
block_sd._ensure_node(block_sd.root(), succ_motif) # type: ignore
block_sd.node_data(block_sd.root())["expanded"] = True

# We could also consider using `seeds` instead of `candidates` here. Ultimately, this
# matters very rarely. The reasoning for why we use `candidates` is that we can (almost)
Expand Down