Skip to content

Commit 2a67d45

Browse files
committed
change array literals to object literals, since the objects are used as associative arrays
1 parent 12cb44c commit 2a67d45

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

chapter09/01-Graph.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function Graph() {
2828
};
2929

3030
var initializeColor = function(){
31-
var color = [];
31+
var color = {};
3232
for (var i=0; i<vertices.length; i++){
3333
color[vertices[i]] = 'white';
3434
}
@@ -93,8 +93,8 @@ function Graph() {
9393

9494
var color = initializeColor(),
9595
queue = new Queue(),
96-
d = [],
97-
pred = [];
96+
d = {},
97+
pred = {};
9898
queue.enqueue(v);
9999

100100
for (var i=0; i<vertices.length; i++){
@@ -128,9 +128,9 @@ function Graph() {
128128
this.DFS = function(){
129129

130130
var color = initializeColor(),
131-
d = [],
132-
f = [],
133-
p = [];
131+
d = {},
132+
f = {},
133+
p = {};
134134
time = 0;
135135

136136
for (var i=0; i<vertices.length; i++){

0 commit comments

Comments
 (0)