@@ -146,7 +146,7 @@ def __init__(
146146 t = min (t , 20 )
147147 else :
148148 k = max (1 , min (self .cfg .k , 100 )) # Safety cap
149- t = max (1 , min (self .cfg .t , 20 )) # Safety cap
149+ t = max (1 , min (self .cfg .t , 20 )) # Safety cap
150150 self .k : int = k
151151 self .t : int = t
152152 self .L : int = max (1 , min (math .ceil (math .log2 (n ) / t ), 10 )) # Cap levels
@@ -215,23 +215,23 @@ def _base_case(self, B: Float, S: Set[Vertex]) -> Tuple[Float, Set[Vertex]]:
215215 seen : Set [Vertex ] = set ()
216216 heap : List [Tuple [Float , Vertex ]] = [(self .dhat [x ], x )]
217217 in_heap : Set [Vertex ] = {x }
218-
218+
219219 # Safety limits to prevent infinite loops
220220 iterations = 0
221221 max_iterations = min (self .k * 1000 , self .G .n * 10 )
222222
223223 while heap and len (U0 ) < self .k + 1 and iterations < max_iterations :
224224 self .counters ["basecase_pops" ] += 1
225225 iterations += 1
226-
226+
227227 du , u = heapq .heappop (heap )
228228 in_heap .discard (u )
229229 if du != self .dhat [u ] or u in seen :
230230 continue
231231 seen .add (u )
232232 self .complete [u ] = True
233233 U0 .append (u )
234-
234+
235235 for v , w in self .G .adj [u ]:
236236 if self ._relax (u , v , w ) and self .dhat [u ] + w < B :
237237 if v not in in_heap :
@@ -262,32 +262,32 @@ def _find_pivots(self, B: Float, S: Set[Vertex]) -> Tuple[Set[Vertex], Set[Verte
262262 """
263263 W : Set [Vertex ] = set (S )
264264 current : Set [Vertex ] = set (S )
265-
265+
266266 # Safety limits for findpivots
267267 iterations = 0
268268 max_iterations = min (self .k * len (S ) * 100 , self .G .n * 10 )
269-
269+
270270 for round_num in range (1 , self .k + 1 ):
271271 if iterations >= max_iterations :
272272 self .counters ["iterations_protected" ] += 1
273273 break
274-
274+
275275 self .counters ["findpivots_rounds" ] += 1
276276 nxt : Set [Vertex ] = set ()
277-
277+
278278 for u in current :
279279 iterations += 1
280280 if iterations >= max_iterations :
281281 break
282-
282+
283283 for v , w in self .G .adj [u ]:
284284 if self ._relax (u , v , w ) and (self .dhat [u ] + w < B ):
285285 nxt .add (v )
286-
286+
287287 if not nxt :
288288 break
289289 W |= nxt
290-
290+
291291 # Early termination if W gets too large
292292 if len (W ) > self .k * max (1 , len (S )) * 5 : # More generous limit
293293 return set (S ), W
@@ -307,7 +307,7 @@ def _find_pivots(self, B: Float, S: Set[Vertex]) -> Tuple[Set[Vertex], Set[Verte
307307 seen : Set [Vertex ] = set ()
308308 iterations = 0
309309 max_tree_iterations = min (self .k * 10 , len (W ))
310-
310+
311311 while stack and iterations < max_tree_iterations :
312312 iterations += 1
313313 a = stack .pop ()
@@ -332,11 +332,13 @@ def _make_frontier(self, level: int, B: Float) -> FrontierProtocol:
332332 return BlockFrontier (M = M , B = B )
333333 raise ConfigError (f"unknown frontier '{ self .cfg .frontier } '" )
334334
335- def _bmssp (self , level : int , B : Float , S : Set [Vertex ], depth : int = 0 ) -> Tuple [Float , Set [Vertex ]]:
335+ def _bmssp (
336+ self , level : int , B : Float , S : Set [Vertex ], depth : int = 0
337+ ) -> Tuple [Float , Set [Vertex ]]:
336338 # Prevent excessive recursion
337339 if depth > 50 or level > 20 :
338340 return self ._base_case (B , S )
339-
341+
340342 if level == 0 :
341343 return self ._base_case (B , S )
342344
@@ -353,7 +355,7 @@ def _bmssp(self, level: int, B: Float, S: Set[Vertex], depth: int = 0) -> Tuple[
353355 while len (U_accum ) < cap and pull_iterations < max_pull_iterations :
354356 self .counters ["pulls" ] += 1
355357 pull_iterations += 1
356-
358+
357359 S_i , B_i = D .pull ()
358360 if not S_i :
359361 Bprime = B
@@ -467,7 +469,7 @@ def path(self, target_original: Vertex) -> List[Vertex]:
467469 seen = set ()
468470 iterations = 0
469471 max_iterations = self .G .n * 2 # Safety limit
470-
472+
471473 while cur is not None and iterations < max_iterations :
472474 iterations += 1
473475 chain .append (cur )
0 commit comments