Skip to content

Commit 21f9fd3

Browse files
committed
update the readme
1 parent 33d14d4 commit 21f9fd3

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

README.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
A fast and memory-efficient implementation of Dijkstra's shortest-path algorithm
44
for Deno.
55

6-
If you ever run into a problem that can be represented as a graph where the
7-
solution has something to do with finding the shortest path between nodes, this
8-
algorithm is nothing short of magical. It is well worth the time to learn how to
9-
use it, even if you don't really understand how the algorithm works.
10-
116
This implementation of Dijkstra'a algorithm is able to process large in-memory
12-
graphs. It will perform reasonably well even when the number of edges is in the
13-
millions. The performance is `O(n*log(n))`, where `n` is proportional to the
14-
number of nodes plus the number of edges in the graph.
7+
graphs. It will perform reasonably well even with millions of edges. The
8+
performance is `O(n*log(n))`, where `n` is proportional to the number of nodes
9+
plus the number of edges in the graph. The use of integers to represent nodes in
10+
the graph is intentional and actually one of the keys to its performance and
11+
scalability.
1512

1613
This code was adapted to Typescript from
1714
[A Walkthrough of Dijkstra's Algorithm (In JavaScript!)](https://medium.com/@adriennetjohnson/a-walkthrough-of-dijkstras-algorithm-in-javascript-e94b74192026)
@@ -37,17 +34,15 @@ deno test --reload
3734

3835
# Usage Hints
3936

40-
Dijkstra's algorithm actually calculates the shortest paths from the start node
41-
to every other node in the graph. In other words, it isn't just calculating one
42-
path at a time. This can let you cheaply do things like find the 20 closest
43-
nodes from a particular node in the graph, for example.
44-
45-
You can reverse the direction of the calculation. Calling it "start node" is
46-
just a convention. It can also be an end node if you set up the graph correctly.
37+
Dijkstra's algorithm calculates the shortest _paths_ from the start node to
38+
_all_ other nodes in the graph. All of them. In other words, it isn't just
39+
calculating one path at a time. This can let you cheaply do things like find the
40+
20 closest nodes from a particular node in the graph, for example.
4741

48-
This implementation supports cloning the solver and extending its graph
49-
dynamically. Graph generation can be expensive. For many cases, most of the
50-
graph can be reused, with a only a small portion needing to be dynamic.
42+
One you have loaded a graph definition into a solver, you can clone it. You can
43+
then add nodes to the cloned graph. Loading a large graph over and over takes
44+
time, and depending on overhead, this can be even slower than calculating the
45+
shortest paths. This type of reuse lets you get super-fast results.
5146

5247
# Example
5348

0 commit comments

Comments
 (0)