Skip to content

Commit 5ee6666

Browse files
committed
[Graphs]
1 parent 0848b4f commit 5ee6666

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

examples/PacktDataStructuresAlgorithms.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/PacktDataStructuresAlgorithms.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/chapter11/03-DFS.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ graph.addEdge('C', 'F');
4646
graph.addEdge('F', 'E');
4747

4848
const result = DFS(graph);
49-
console.log(result.discovery);
50-
console.log(result.finished);
51-
console.log(result.predecessors);
49+
console.log('discovery', result.discovery);
50+
console.log('finished', result.finished);
51+
console.log('predecessors', result.predecessors);
5252

5353
const fTimes = result.finished;
5454
s = '';

src/js/algorithms/graph/depth-first-search.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const depthFirstSearch = (graph, callback) => {
4646
const DFSVisit = (u, color, d, f, p, time, adjList) => {
4747
// console.log('discovered ' + u);
4848
color[u] = Colors.GREY;
49-
d[u] = ++time;
49+
d[u] = ++time.count;
5050
const neighbors = adjList.get(u);
5151
for (let i = 0; i < neighbors.length; i++) {
5252
const w = neighbors[i];
@@ -56,7 +56,7 @@ const DFSVisit = (u, color, d, f, p, time, adjList) => {
5656
}
5757
}
5858
color[u] = Colors.BLACK;
59-
f[u] = ++time;
59+
f[u] = ++time.count;
6060
// console.log('explored ' + u);
6161
};
6262

@@ -67,7 +67,7 @@ export const DFS = graph => {
6767
const d = {};
6868
const f = {};
6969
const p = {};
70-
const time = 0;
70+
const time = { count: 0 };
7171
for (let i = 0; i < vertices.length; i++) {
7272
f[vertices[i]] = 0;
7373
d[vertices[i]] = 0;

src/js/data-structures/graph.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class Graph {
2020
this.addVertex(b);
2121
}
2222
this.adjList.get(a).push(b);
23-
if (!this.isDirected) {
23+
if (this.isDirected !== true) {
2424
this.adjList.get(b).push(a);
2525
}
2626
}

0 commit comments

Comments
 (0)