Potential Inefficiency and Missed Priority Updates in Dijkstra's Algorithm Implementation

Aperta
#2,056 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
data

Direzione di ricerca

Locate the Dijkstra implementation and the PriorityQueue implementation, then inspect how hasValue, changePriority, and duplicate entries behave. Add or update coverage for a shorter path when the neighbor is absent or already present, and confirm the queue preserves the intended priority without duplicates.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

In the Dijkstra algorithm, when a shorter path to a neighbor is found, the neighbor's priority in the priority queue should be updated regardless of whether it is already present in the queue.
In this code, the priority is only changed if queue.hasValue(neighbor) returns true. However, if a neighbor is not yet in the queue, it is added; but if it's already present, the code changes its priority.
This logic is correct as long as queue.changePriority works as intended, but it could be fragile if there are issues in the PriorityQueue implementation (such as not truly updating priorities or not handling duplicates). If the PriorityQueue does not remove duplicates, a neighbor may exist multiple times in the queue with different priorities.

Lingua principale
JavaScript
Stelle
197k
Fork
31k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di trekhleb/javascript-algorithms

Tutte le issue di trekhleb/javascript-algorithms

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.