Skip to content

Commit cb52e6b

Browse files
committed
Graph alg explanations
1 parent d45dc24 commit cb52e6b

File tree

6 files changed

+23
-29
lines changed

6 files changed

+23
-29
lines changed

src/algorithms/explanations/ASTExp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ As these algorithms execute, we can classify nodes into three sets.
3232
These are:
3333

3434

35-
- "Finalised" nodes, for which the shortest or least costly path back to the start node has already
36-
been finalised, that is the final parent node has been determined and is recorded;
35+
- "Finalised" nodes, for which the path back to the start node has
36+
been finalised, that is, the final parent node has been determined and recorded;
3737

3838
- "Frontier" nodes, that are not finalised but are connected to a finalised node by a single edge; and
3939

@@ -46,8 +46,8 @@ The frontier initially contains just the start node. The algorithms repeatedly
4646
pick a frontier node, finalise the node (its current parent becomes
4747
its final parent) and update information about the neighbours of the node.
4848
A\* uses a priority queue for the frontier nodes,
49-
ordered on the shortest distance to the node found so far *plus* the
50-
heuristic value of the node. At each
49+
ordered on the shortest distance from the start node
50+
to the node found so far *plus* the heuristic value of the node. At each
5151
stage the node with the minimum cost
5252
is removed for processing, and its neighbors have their information
5353
updated if a shorter path has now been found.

src/algorithms/explanations/BFSExp.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ As these algorithms execute, we can classify nodes into three sets.
2929
These are:
3030

3131

32-
- "Finalised" nodes, for which the shortest or least costly path back to the start node has already
33-
been finalised, that is the final parent node has been determined and is recorded;
32+
- "Finalised" nodes, for which the path back to the start node has
33+
been finalised, that is, the final parent node has been determined and recorded;
34+
3435

3536
- "Frontier" nodes, that are not finalised but are connected to a finalised node by a single edge; and
3637

src/algorithms/explanations/DFSExp.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ As these algorithms execute, we can classify nodes into three sets.
3030
These are:
3131

3232

33-
- "Finalised" nodes, for which the shortest or least costly path back to the start node has already
34-
been finalised, that is the final parent node has been determined and is
35-
recorded (DFS is an exception in that path lengths/costs are ignored and
36-
finalised nodes can have very long paths to them);
33+
- "Finalised" nodes, for which the path back to the start node has
34+
been finalised, that is, the final parent node has been determined and recorded;
35+
3736

3837
- "Frontier" nodes, that are not finalised but are connected to a finalised node by a single edge; and
3938

src/algorithms/explanations/DFSrecExp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This recursive coding is very simple: the core is a recursive
1414
function that is called with a node n and a parent p. If the parent of
1515
n has not yet been decided it assigns p as the parent and recursively
1616
calls the function on all nodes neighbouring n, with n as the parent,
17-
until an end node is found or all nodes in the componenent have been
17+
until an end node is found or all nodes in the component have been
1818
examined.
1919

2020
Elsewhere we have an iterative version of DFS.
@@ -29,10 +29,10 @@ As these algorithms execute, we can classify nodes into three sets.
2929
These are:
3030

3131

32-
- "Finalised" nodes, for which the shortest or least costly path back to the start node has already
33-
been finalised, that is the final parent node has been determined and is
34-
recorded (DFS is an exception in that path lengths/costs are ignored and
35-
finalised nodes can have very long paths to them);
32+
- "Finalised" nodes, for which the path back to the start node has
33+
been finalised, that is, the final parent node has been determined and
34+
recorded;
35+
3636

3737
- "Frontier" nodes, that are not finalised but are connected to a finalised node by a single edge; and
3838

src/algorithms/explanations/DIJKExp.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ As these algorithms execute, we can classify nodes into three sets.
2929
These are:
3030

3131

32-
- "Finalised" nodes, for which the shortest or least costly path back to the start node has already
33-
been finalised, that is the final parent node has been determined and is recorded;
32+
- "Finalised" nodes, for which the path back to the start node has
33+
been finalised, that is, the final parent node has been determined and recorded;
34+
3435

3536
- "Frontier" nodes, that are not finalised but are connected to a finalised node by a single edge; and
3637

@@ -43,7 +44,8 @@ The frontier initially contains just the start node. The algorithms repeatedly
4344
pick a frontier node, finalise the node (its current parent becomes
4445
its final parent) and update information about the neighbours of the node.
4546
Dijkstra's algorithm uses a priority queue for the frontier nodes,
46-
ordered on the shortest distance to the node found so far. At each
47+
ordered on the shortest distance from the start node
48+
to the node found so far. At each
4749
stage the node with the minimum cost
4850
is removed for processing, and its neighbors have their information
4951
updated if a shorter path has now been found.

src/algorithms/explanations/PRIMExp.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ As these algorithms execute, we can classify nodes into three sets.
3232
These are:
3333

3434

35-
- "Finalised" nodes, for which the shortest or least costly path back to the start node has already
36-
been finalised (see below for further explanation of this),
37-
that is the final parent node has been determined and is recorded;
35+
- "Finalised" nodes, for which the path back to the start node has
36+
been finalised, that is, the final parent node has been determined and recorded;
37+
3838

3939
- "Frontier" nodes, that are not finalised but are connected to a finalised node by a single edge; and
4040

@@ -54,14 +54,6 @@ been finalised
5454
have their costs recomputed. Other algorithms use other data structures to keep track
5555
of the frontier nodes.
5656

57-
Saying the finalised nodes have "the least costly path" back to the start
58-
node may be a little misleading: Prim's algorithm uses the length of just
59-
*the first edge of the path* as the cost. At each step, Prim's algorithm
60-
chooses the node with the least *incremental* cost increase for the tree
61-
being constructed. Throughout the execution, if finalised has size *N*,
62-
it contains the smallest tree with *N* nodes that includes the start node.
63-
The paths from each node back to the start are generally not the shortest.
64-
6557
In the presentation here, we do not give details of how the priority
6658
queue is implemented, but just emphasise it is a collection of nodes
6759
with associated costs and the node with the minimum cost is selected each

0 commit comments

Comments
 (0)