Skip to content

Commit

Permalink
fixed flooding and djikstra
Browse files Browse the repository at this point in the history
  • Loading branch information
algasami committed Jun 5, 2024
1 parent 87eb578 commit 7933004
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/[lang]/graph/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@ export default function Graph({ params }: { params: { lang: Locale } }) {
pq.length == 0 ||
start === undefined ||
end === undefined ||
completeness
)
(algo === 0 && completeness)
) {
set_front(end);
return;
}
const pqcopy = [...pq];

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

visited.set(firstkey, true);
set_total_visited(total_visited + 1);
if (node_first.x === end.x && node_first.y === end.y) {
if (node_first.x === end.x && node_first.y === end.y && algo === 0) {
set_pq([]);
set_front(end);
return;
}
// get adjs
Expand Down Expand Up @@ -258,7 +261,7 @@ export default function Graph({ params }: { params: { lang: Locale } }) {
pq_calc(right_adj);
pqcopy.sort((a, b) => a.priority - b.priority);
set_pq(pqcopy);
}, 10);
}, 5);
return () => {
clearTimeout(conn);
};
Expand Down

0 comments on commit 7933004

Please sign in to comment.