undf: remove 29 clean scan entries from registry (retired IDs preserved as gaps)

This commit is contained in:
russell@unturf.com 2026-03-28 13:11:33 -04:00
parent 0ee2c5acaf
commit 323b0faf49
4 changed files with 145 additions and 30 deletions

View file

@ -0,0 +1,29 @@
--- a/networkx/algorithms/connectivity/kcutsets.py
+++ b/networkx/algorithms/connectivity/kcutsets.py
@@ -100,8 +100,12 @@ def all_node_cuts(G, k=None, flow_func=None):
# Initialize data structures.
# Keep track of the cuts already computed so we do not repeat them.
- seen = []
+ # CWE-407 fix: `not in seen` was O(K) where K is the number of cuts
+ # found so far (list scan). Each iteration in the triple-nested loop
+ # (for x in X: for v in non_adjacent: for antichain in antichains(L):)
+ # pays this cost. Fix: use a set of frozensets for O(1) lookup.
+ # node_cut is a plain set so we freeze before inserting/checking.
+ seen = set()
...
# Check if X is a k-node-cutset
if _is_separating_set(G, X):
- seen.append(X)
+ seen.add(frozenset(X))
yield X
...
# Inside the triple-nested loop:
if len(node_cut) == k:
if x in node_cut or v in node_cut:
continue
- if node_cut not in seen:
+ frozen_cut = frozenset(node_cut)
+ if frozen_cut not in seen: # O(1) hash lookup
yield node_cut
- seen.append(node_cut)
+ seen.add(frozen_cut) # O(1) insert