2323 'all_pair_shortest_paths' ,
2424 'topological_sort' ,
2525 'topological_sort_parallel' ,
26- 'max_flow'
26+ 'max_flow' ,
2727]
2828
2929Stack = Queue = deque
@@ -851,20 +851,20 @@ def heuristic(node: str, goal: str) -> float:
851851 dist = {v : float ('inf' ) for v in graph .vertices }
852852 pred = {v : None for v in graph .vertices }
853853 dist [source ] = 0
854- # Priority queue using f-score (g_score + heuristic)
855- pq = PriorityQueue (implementation = 'binomial_heap' )
856- pq .push (source , heuristic (source , target ))
857- while not pq .is_empty ():
854+ from pydatastructs .miscellaneous_data_structures .queue import PriorityQueue , BinomialHeapPriorityQueue
855+ pq = PriorityQueue (implementation = 'binomial_heap' )
856+ f_score = heuristic (source , target )
857+ pq .push (source , f_score )
858+ while not pq .is_empty :
858859 current = pq .pop ()
859860 if current == target :
860- print (f"Returning: { dist [target ]} , { pred } " )
861861 return dist [target ], pred
862862 if visited [current ]:
863863 continue
864- visited [current ] = True
864+ visited [current ] = True
865865 neighbors = graph .neighbors (current )
866866 if not neighbors :
867- continue
867+ continue
868868 for neighbor in neighbors :
869869 if visited [neighbor .name ]:
870870 continue
@@ -877,10 +877,8 @@ def heuristic(node: str, goal: str) -> float:
877877 pred [neighbor .name ] = current
878878 f_score = new_dist + heuristic (neighbor .name , target )
879879 pq .push (neighbor .name , f_score )
880- print (f"Returning: { float ('inf' )} , { pred } " )
881880 return float ('inf' ), pred
882881_a_star_adjacency_matrix = _a_star_adjacency_list
883-
884882def all_pair_shortest_paths (graph : Graph , algorithm : str ,
885883 ** kwargs ) -> tuple :
886884 """
0 commit comments