Skip to content

Commit 699aa71

Browse files
improved reading
1 parent c2dd7c7 commit 699aa71

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

flowpaths/abstractwalkmodeldigraph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ def _encode_walks(self):
221221

222222
# Edge selected constraints
223223

224-
# 19a: If y[(u,v,i)] = 1, then x[(u,v,i)] = 1
225-
# Equivalently, y[(u,v,i)] cannot be 1 without x[(u,v,i)] being 1
224+
# 19a: If y[(u,v,i)] = 1, then x[(u,v,i)] >= 1
225+
# Equivalently, y[(u,v,i)] cannot be 1 without x[(u,v,i)] being at least 1
226226
for i in range(self.k):
227227
for (u,v) in self.G.edges:
228228
self.solver.add_constraint(

flowpaths/utils/graphutils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from itertools import count
22
import networkx as nx
33
import flowpaths.utils as utils
4+
# NOTE: Do NOT import flowpaths.stdigraph at module import time to avoid a circular
5+
# import chain: stdag -> graphutils -> stdigraph -> stdag. We instead lazily import
6+
# stdigraph inside functions that need it (e.g. read_graph) after this module is fully loaded.
47

58
bigNumber = 1 << 32
69

@@ -125,6 +128,12 @@ def read_graph(graph_raw) -> nx.DiGraph:
125128
utils.logger.error(f"{__name__}: Constraint edge ({u}, {v}) not found in graph {graph_id} edges.")
126129
raise ValueError(f"Constraint edge ({u}, {v}) not found in graph edges.")
127130

131+
G.graph["n"] = G.number_of_nodes()
132+
G.graph["m"] = G.number_of_edges()
133+
# Lazy import here to avoid circular import at module load time
134+
from flowpaths import stdigraph as _stdigraph # type: ignore
135+
G.graph["w"] = _stdigraph.stDiGraph(G).get_width()
136+
128137
return G
129138

130139

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "flowpaths"
3-
version = "0.2.00"
3+
version = "0.2.1"
44
description = "A Python package to quickly decompose weighted graphs into weights paths, under various models."
55
readme = "README.md"
66
authors = [{name="Graph Algorithms and Bioinformatics Group @ University of Helsinki, and external collaborators"}]

0 commit comments

Comments
 (0)