Skip to content

Commit a523a9e

Browse files
committed
small bug fix
1 parent ba2770c commit a523a9e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pymatgen_diffusion/neb/periodic_dijkstra.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ def periodic_dijkstra(
9999
min_val, (cur_idx, cur_image) = heapq.heappop(pq)
100100
if target_reached(cur_idx, cur_image):
101101
return best_ans
102-
best_ans[(cur_idx, cur_image)] = min_val
102+
if min_val < best_ans[(cur_idx, cur_image)]:
103+
best_ans[(cur_idx, cur_image)] = min_val
103104
for next_node, keyed_data in conn_dict[cur_idx].items():
104105
for k, d in keyed_data.items():
105106
# get the node index, image pair
@@ -112,10 +113,11 @@ def periodic_dijkstra(
112113
new_cost = min_val + d[weight]
113114

114115
if new_cost < best_ans[next_index_pair]:
115-
best_ans[(next_node, new_image)] = new_cost
116-
path_parent[(next_node, new_image)] = (cur_idx, cur_image)
117-
heapq.heappush(pq, (new_cost, (next_node, new_image)))
118-
return best_ans, path_parent
116+
best_ans[next_index_pair] = new_cost
117+
path_parent[next_index_pair] = (cur_idx, cur_image)
118+
heapq.heappush(pq, (new_cost, next_index_pair))
119+
120+
# return best_ans, path_parent
119121

120122

121123
def periodic_dijkstra_on_sgraph(

0 commit comments

Comments
 (0)