Dijkstra? ????? ??? ???? ???? ?? ?????? ?? ?? ????? ?? ??? ?? ? ???? ???? ?? ?? ???????. ? ????? ????? ??? ??? ???? JavaScript? ???? ??? ?????.
Dijkstra? ?????? ??????
Dijkstra? ????? ?? ?? ?? ???? ?? ??? ????? ?? ?? ????? ?? ??? ??? ??? ????? ???????. 1956? Edsger W. Dijkstra? ??? ? ????? ??? ???? ?? ?? ???? ???? ? ??? ?? ????.
?? ? ??
- ??: ??? G=(V,E) , ?? ? ? ??? ????, E ? ?? ???? ?? ?????. s∈?
- . ??: ?? ?? ?? ? ?? ?? ??? ?
-
?? ??
- ??:
- ??? ????? ?? ??? ?????? ???????. ???? ?:
- ?? ??? ?? ?? ??? ????? ?????. ??? ?? ??:
-
????
-
??(s)=0,??(v)=?v=s ???? ???? ???? ??? ?? ??? ?????.
??? ?? ?? ??? ????? ???? ?? ??? ??????.
?? - ??? ??
- ???: ??(s)=0,??(v)= llv=
?? (?) ?? ????, (v) ?? ??? ?????.
-
?? ??: ? ????? ??
(u,v)
???
w(u,v)
:
???
dist(v)>dist (?) w(u,v)
, ????:
??(v)=??(u) w(u,v),prev(v)=u
?? ??: ??? ? ?? ??? ???? ??? ????? ?????? ?? ????? ?? ??? ??? ?????.
???? ??? - ??? ??
-
? ??:
- ???? ???? ?? ??? ????? ?????.
(?)
?? ??? ?? ?? ??:
u=arg v∈Q ????(v)
- ?? ??: ?? ?? ??? ???? (dist(v)) , ??? ???? ????? ?? ??? ?????. (?) .
- ???? ???? ?? ??? ????? ?????.
(?)
?? ??? ?? ?? ??:
??? ??
?? ??? ???? Dijkstra ????? ???? ?????.
?????? ??????
????? ??? ???? ????, ??? ???? ?? (P(n)) , ??? (P(1),P(2),…,P(k)) ???? ( P(k 1)) . ?? ?? ???? ????. (P(k)) ???? ( P(k 1)) . ?? ????? ? ??? ?????.
????? ????? ???(??? ??)
?? ??:
?? ?? (?) ? ?????? ??(s)=0 , ????.??? ??:
???? ??? ?? ??? ?? ?? ??? ????? ?????.?? ??:
?? ?? (?) ???? ??? ?????. ?? ??(u) ? ?? ?? ???? ?? ?? ??? ??? ?????. ??(u) ? ????.
?????? ??
?? ??(???? ???):
// Simplified Queue using Sorting // Use Binary Heap (good) // or Binomial Heap (better) or Pairing Heap (best) class PriorityQueue { constructor() { this.queue = []; } enqueue(node, priority) { this.queue.push({ node, priority }); this.queue.sort((a, b) => a.priority - b.priority); } dequeue() { return this.queue.shift(); } isEmpty() { return this.queue.length === 0; } }
??? ???? ???? ???? Dijkstra ????? JavaScript ?????.
function dijkstra(graph, start) { const distances = {}; // hold the shortest distance from the start node to all other nodes const previous = {}; // Stores the previous node for each node in the shortest path (used to reconstruct the path later). const pq = new PriorityQueue(); // Used to efficiently retrieve the node with the smallest tentative distance. // Initialize distances and previous for (let node in graph) { distances[node] = Infinity; // Start with infinite distances previous[node] = null; // No previous nodes at the start } distances[start] = 0; // Distance to the start node is 0 pq.enqueue(start, 0); while (!pq.isEmpty()) { const { node } = pq.dequeue(); // Get the node with the smallest tentative distance for (let neighbor in graph[node]) { const distance = graph[node][neighbor]; // The edge weight const newDist = distances[node] + distance; // Relaxation Step if (newDist < distances[neighbor]) { distances[neighbor] = newDist; // Update the shortest distance to the neighbor previous[neighbor] = node; // Update the previous node pq.enqueue(neighbor, newDist); // Enqueue the neighbor with the updated distance } } } return { distances, previous }; } // Example usage const graph = { A: { B: 1, C: 4 }, B: { A: 1, C: 2, D: 5 }, C: { A: 4, B: 2, D: 1 }, D: { B: 5, C: 1 } }; const result = dijkstra(graph, 'A'); // start node 'A' console.log(result);
?? ???
// Simplified Queue using Sorting // Use Binary Heap (good) // or Binomial Heap (better) or Pairing Heap (best) class PriorityQueue { constructor() { this.queue = []; } enqueue(node, priority) { this.queue.push({ node, priority }); this.queue.sort((a, b) => a.priority - b.priority); } dequeue() { return this.queue.shift(); } isEmpty() { return this.queue.length === 0; } }
?? ??
??? ??
- ??: A,B,C,D
-
????:
- A→B=(1),A→C=(4)
- B→C=(2),B→D=(5)
- C→D=(1)
??? ??
-
?? ???:
??(A)=0,??(B)= ,??(C)=,??(D)=??? -
???? A:
- ???? ??:
??(B)= ???? B: ???? ??:
- ???? ??:
??(B
- →C
- ,B??(?)= ???? C: ??? ????:
- ,B??(?
- →D
- .C~D. ??(?)=
- .C~D. ??(?
? ??? Dijkstras ???? ??: ???? ????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











Java ? JavaScript? ?? ?? ????? ??? ?? ?? ?? ???? ????? ?????. Java? ??? ? ??? ?????? ??? ???? JavaScript? ?? ? ??? ??? ?????.

JavaScript?? ??? ??? ?? ? ? ?? ??? ???????. 1. ?? ??? ??? ???? ?? ??? ????. ISO ?? ???? ???? ???? ???? ?? ????. 2. ?? ??? ?? ???? ??? ?? ???? ??? ? ??? ? ?? 0?? ????? ?? ??????. 3. ?? ?? ???? ???? ???? ?? ?????? ??? ? ????. 4. Luxon? ?? ???? ???? ?????? ???? ?? ????. ??? ?? ???? ????? ???? ??? ????? ?? ? ????.

TAGGSATTHEBOTTOMOFABLOGPOSTORWEBPAGESERVESPRACTICALPURSEO, USEREXPERIENCE, andDESIGN.1.ITHELPSWITHEOBYOWNSESPORENGENSTOESTOCESKESKERKESKERKERKERDER-RELEVANTTAGSWITHOUTHINGTEMAINCONTENT.2.ITIMPROVESEREXPERKEEPINGTOPONTEFOCUSOFOFOFOCUSOFOFOFOCUCUSONTHEATECLL

JavaScriptIspreferredforwebDevelopment, whithjavaisbetterforlarge-scalebackendsystemsandandandoidapps.1) javascriptexcelsincreatinginteractivewebexperiences withitsdynatureanddommanipulation.2) javaoffersstrongtypingandobject-Orientededededededededededededededededdec

??? ?? ? ??? DOM?? ??? ??? ? ?????. ??? ?? ????? ?? ??????, ??? ?? ???? ?? ????????. 1. ??? ??? addeventListener? usecapture ?? ??? true? ???? ?????. 2. ??? ??? ?? ???? usecapture? ???? ????? ?????. 3. ??? ??? ??? ??? ???? ? ??? ? ????. 4. ??? ?? ?? ?? ??? ?? ??? ??????? ??? ???? ?????. 5. ??? ?? ?? ?? ??? ?? ???? ?? ???? ? ??? ? ????. ? ? ??? ???? ???? JavaScript? ??? ??? ??? ????? ???? ???? ??? ??????.

javascriptassevenfundamentalDatatatypes : ??, ???, ??, unull, ??, ? symbol.1) ?? seAdouble-precisionformat, ??? forwidevaluerangesbutbecautiouswithfatingfointarithmetic.2) stringsareimmutable, useefficientconcatenationmethendsf

JavaScript ?? ????? ??????? ??? ?? ??? ??? ????? ?? ??? ????. ????? ??? ?????. 1. ?? ?? (CodesPlitting) ??, ?? ??? React.lazy ()? ?? ?? ?? ?? ??? ????? ??? ???? ? ?? ????? ??? ?? ??? ???????. 2. ???? ?? ?? (???)? ????, ES6 ?? ????? ???? "Dead Code"? ???? ?? ? ????? ?? ??? ??? ? ???????. 3. ?? ??? ???? ???? GZIP/BROTLI ? TERSER? JS? ???? ??? ????? ???? ?? ???? ??? ? ? ??????. 4. ??? ???? ???? day.js ? fetch? ?? ?? ?????? ??????.

ES ??? CommonJS? ?? ???? ?? ?? ? ?? ???????. 1. Commonjs? ????????? Node.js ?? ? ??? ?????. 2.ES ??? ???????? ????? ?? ???? ??? ?????. 3. ??, ES ??? ?? ??/????? ???? ??? ??? ?????? CommonJS? Quiew/Module.exports? ???? ???? ???? ?? ? ? ????. 4. Commonjs? Express? ?? ???? Node.js ? ?????? ?? ???? ?? ???? ?? ES ??? ?? ??? ?? ??? ?? ? Node.jsv14? ?????. 5. ?? ? ? ??? ?? ??? ??? ? ????.
