Skip to content

Commit 7f67ce8

Browse files
committed
\Replace kMinFlow with kEpsilon for flow threshold checks in place_on_dag and max_flow functions
1 parent 82da627 commit 7f67ce8

4 files changed

Lines changed: 11 additions & 8 deletions

File tree

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
VENV_BIN := $(PWD)/venv/bin
88
# Use dynamic (recursive) assignment so a newly created venv is picked up
9-
# Prefer the python3 on PATH (e.g., set by setup-python)
10-
PY_FIND := $(shell command -v python3 2>/dev/null || command -v python 2>/dev/null)
9+
# Prefer explicit versions first (newest to oldest), then python3 on PATH
10+
PY_FIND := $(shell for v in 3.13 3.12 3.11 3.10; do command -v python$$v >/dev/null 2>&1 && { echo python$$v; exit 0; }; done; command -v python3 2>/dev/null || command -v python 2>/dev/null)
1111
PYTHON ?= $(if $(wildcard $(VENV_BIN)/python),$(VENV_BIN)/python,$(PY_FIND))
1212
PIP = $(PYTHON) -m pip
1313
PYTEST = $(PYTHON) -m pytest
@@ -123,13 +123,13 @@ build:
123123

124124
clean:
125125
@echo "🧹 Cleaning build artifacts and cache files..."
126-
@rm -rf build/ dist/ *.egg-info/
126+
@rm -rf build/ dist/ *.egg-info/ || true
127127
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
128128
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
129129
@find . -type f -name "*.pyo" -delete 2>/dev/null || true
130-
@rm -f .coverage coverage-*.xml coverage-*.html
131-
@rm -rf htmlcov-python
132-
@rm -rf Testing CTestTestfile.cmake
130+
@rm -f .coverage coverage-*.xml coverage-*.html || true
131+
@rm -rf htmlcov-python || true
132+
@rm -rf Testing CTestTestfile.cmake || true
133133
@echo "✅ Cleanup complete!"
134134

135135
info:

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ dev = [
4141
"pre-commit",
4242
"build",
4343
"twine",
44+
"cmake>=3.23",
45+
"ninja",
4446
]
4547

4648
[project.urls]

src/flow_state.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,15 @@ Flow FlowState::place_on_dag(NodeId src, NodeId dst, const PredDAG& dag,
324324
while (!q.empty()) {
325325
auto u = q.front(); q.pop();
326326
double f_in = inflow[static_cast<std::size_t>(u)];
327-
if (f_in < kMinFlow) continue;
327+
if (f_in < kEpsilon) continue;
328328
int split = node_split[static_cast<std::size_t>(u)];
329329
if (split <= 0) continue;
330330
for (auto gi : succ[static_cast<std::size_t>(u)]) {
331331
const auto& gr = groups[gi];
332332
if (gr.eids.empty()) continue;
333333
// Group share proportional to number of edges (equal per-edge split).
334334
double push = f_in * (static_cast<double>(gr.eids.size()) / static_cast<double>(split));
335-
if (push < kMinFlow) continue;
335+
if (push < kEpsilon) continue;
336336
assigned[gi] += push;
337337
auto v = static_cast<std::size_t>(gr.from);
338338
inflow[v] += push;

src/max_flow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ calc_max_flow(const StrictMultiDiGraph& g, NodeId src, NodeId dst,
8080

8181
Cost path_cost = dist[static_cast<std::size_t>(dst)];
8282
Flow placed = fs.place_on_dag(src, dst, dag, std::numeric_limits<double>::infinity(), placement);
83+
8384
if (placed < kMinFlow) break;
8485
total += placed;
8586
// Merge by exact cost (integer)

0 commit comments

Comments
 (0)