Skip to content

Commit bde11c3

Browse files
committed
Top level fn comments/explanations
1 parent ef948c4 commit bde11c3

File tree

7 files changed

+49
-32
lines changed

7 files changed

+49
-32
lines changed

src/algorithms/pseudocode/AStar.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ import parse from '../../pseudocode/parse';
33
export default parse(`
44
\\Code{
55
Main
6-
Astar(G, s, e) // Given a graph G find a shortest path from start node s \\B 1
7-
// to the end node e. Nodes are numbered 1..nmax. Returns the
8-
// Parent array, which gives the previous node in the path from s
9-
// to the node i (if one has been found; Parent[i] = 0 otherwise).
10-
// A heuristic function is used to guide the search (here it is based
11-
// on a measure of the distance from each node to e).
6+
Astar(G, s, e) // Heuristic search for node e from node s in graph G \\B 1
7+
\\Expl{ Given a graph G, find a path from start node s
8+
to the end node e. Nodes are numbered 1..nmax. Returns the
9+
Parent array, which gives the previous node in the path from s
10+
to the node i (if one has been found; Parent[i] = 0 otherwise).
11+
A heuristic function is used to guide the search (here it is
12+
a measure of the distance from each node to e, based on
13+
the Euclidiean coordinates of each node). If the
14+
heuristic is "admissible", the shortest path will be found.
15+
\\Expl}
16+
1217
\\In{
1318
initialise, with fontier={s}, stored in Nodes \\Ref Init
1419
while Nodes is not empty \\B 2

src/algorithms/pseudocode/BFS.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import parse from '../../pseudocode/parse';
33
export default parse(`
44
\\Code{
55
Main
6-
BFS(G, s) // Given a graph G find a path from start node s to an \\B 1
7-
// end node. It is assumed the end node(s) are defined
8-
// separately; if there are no end nodes, paths to all connected
9-
// nodes are found. Nodes are numbered 1..nmax. Returns the Parent
10-
// array, which gives the previous node in the path from s to the
11-
// node i (if one has been found; Parent[i] = 0 otherwise).
6+
BFS(G, s) // Breadth first search of graph G from start node s \\B 1
7+
\\Expl{ Given a graph G, find a path from the start node s to an
8+
end node. It is assumed the end node(s) are defined
9+
separately; if there are no end nodes, paths to all connected
10+
nodes are found. Nodes are numbered 1..nmax. Returns the Parent
11+
array, which gives the previous node in the path from s to the
12+
node i (if one has been found; Parent[i] = 0 otherwise).
13+
\\Expl}
1214
\\In{
1315
initialise, with fontier={s}, stored in Nodes \\Ref Init
1416
while Nodes is not empty \\B 2

src/algorithms/pseudocode/DFS.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import parse from '../../pseudocode/parse';
33
export default parse(`
44
\\Code{
55
Main
6-
DFS(G, s) // Given a graph G find a path from start node s to an \\B 1
7-
// end node. It is assumed the end node(s) are defined
8-
// separately; if there are no end nodes, paths to all connected
9-
// nodes are found. Nodes are numbered 1..nmax. Returns the Parent
10-
// array, which gives the previous node in the path from s to the
11-
// node i (if one has been found; Parent[i] = 0 otherwise).
6+
DFS(G, s) // Depth first search of graph G from start node s \\B 1
7+
\\Expl{ Given a graph G, find a path from the start node s to an
8+
end node. It is assumed the end node(s) are defined
9+
separately; if there are no end nodes, paths to all connected
10+
nodes are found. Nodes are numbered 1..nmax. Returns the Parent
11+
array, which gives the previous node in the path from s to the
12+
node i (if one has been found; Parent[i] = 0 otherwise).
13+
\\Expl}
1214
\\In{
1315
initialise, with fontier={s}, stored in Nodes \\Ref Init
1416
while Nodes is not empty \\B 2

src/algorithms/pseudocode/DFSrec.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ made explicit
2626
2727
\\Code{
2828
Main
29-
DFS(G, n) // Given a graph G find a path from start node n to a \\B start
30-
// separately defined end node; if there are no end nodes, paths
31-
// to all connected nodes are found.
29+
DFS(G, n) // Depth first search of graph G from start node n \\B start
30+
\\Expl{ Given a graph G, find a path from the start node n to an
31+
end node. It is assumed the end node(s) are defined
32+
separately; if there are no end nodes, paths to all connected
33+
nodes are found. Nodes are numbered 1..nmax. Returns the Parent
34+
array, which gives the previous node in the path from s to the
35+
node i (if one has been found; Parent[i] = 0 otherwise).
36+
\\Expl}
37+
3238
\\In{
3339
initialise all parents to null \\B init
3440
\\Expl{ We initialise to some special value so we can later check if a

src/algorithms/pseudocode/TTFTreeInsertion.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ to the page of the file-system.
8787
8888
\\Code{
8989
Main
90-
T234_Insert(t, k) // return either a node containing key k or \\B T234_Insert(t, k)
91-
// NotFound, if no such node is present
90+
T234_Insert(t, k) // Insert key k into 234 tree t \\B T234_Insert(t, k)
9291
\\In{
9392
if t = Empty \\B if t = Empty
9493
\\In{
@@ -546,4 +545,4 @@ to the page of the file-system.
546545
\\In}
547546
548547
\\Note}
549-
`);
548+
`);

src/algorithms/pseudocode/dijkstra.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import parse from '../../pseudocode/parse';
33
export default parse(`
44
\\Code{
55
Main
6-
Shortest(G, s) //Given a graph G find a shortest path from start node s \\B 1
7-
// to an end node. It is assumed the end node(s) are defined
8-
// separately; with no end nodes, shortest paths to all connected
9-
// nodes are found. Nodes are numbered 1..nmax. Returns the Parent
10-
// array, which gives the previous node in the path from s to the
11-
// node i (if one has been found; Parent[i] = 0 otherwise).
6+
Shortest(G, s) // Find shortest path(s) from start node s in graph G \\B 1
7+
\\Expl{ Given a graph G, find a shortest path from start node s
8+
to an end node. It is assumed the end node(s) are defined
9+
separately; with no end nodes, shortest paths to all connected
10+
nodes are found. Nodes are numbered 1..nmax. Returns the Parent
11+
array, which gives the previous node in the path from s to the
12+
node i (if one has been found; Parent[i] = 0 otherwise).
13+
\\Expl}
14+
1215
\\In{
1316
initialise, with fontier={s}, stored in Nodes \\Ref Init
1417
while Nodes is not empty \\B 2

src/algorithms/pseudocode/transitiveClosure.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import parse from '../../pseudocode/parse';
33
export default parse(`
44
\\Code{
55
Main
6-
Warshall(A, n) \\B 1
7-
\\Expl{ Compute the transitive closure of a directed graph G
6+
Warshall(A, n) // Compute the transitive closure of a graph \\B 1
7+
\\Expl{ Compute the transitive closure of a directed graph
88
with nodes 1..n, represented by n x n adjacency matrix A
99
\\Expl}
1010
\\In{

0 commit comments

Comments
 (0)