Skip to content

Commit 7933004

Browse files
committed
fixed flooding and djikstra
1 parent 87eb578 commit 7933004

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app/[lang]/graph/page.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,11 @@ export default function Graph({ params }: { params: { lang: Locale } }) {
191191
pq.length == 0 ||
192192
start === undefined ||
193193
end === undefined ||
194-
completeness
195-
)
194+
(algo === 0 && completeness)
195+
) {
196+
set_front(end);
196197
return;
198+
}
197199
const pqcopy = [...pq];
198200

199201
const node_first = pqcopy.shift().node;
@@ -202,8 +204,9 @@ export default function Graph({ params }: { params: { lang: Locale } }) {
202204

203205
visited.set(firstkey, true);
204206
set_total_visited(total_visited + 1);
205-
if (node_first.x === end.x && node_first.y === end.y) {
207+
if (node_first.x === end.x && node_first.y === end.y && algo === 0) {
206208
set_pq([]);
209+
set_front(end);
207210
return;
208211
}
209212
// get adjs
@@ -258,7 +261,7 @@ export default function Graph({ params }: { params: { lang: Locale } }) {
258261
pq_calc(right_adj);
259262
pqcopy.sort((a, b) => a.priority - b.priority);
260263
set_pq(pqcopy);
261-
}, 10);
264+
}, 5);
262265
return () => {
263266
clearTimeout(conn);
264267
};

0 commit comments

Comments
 (0)