File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -224,18 +224,18 @@ Graph.prototype.neighbors = function(node) {
224
224
} ;
225
225
226
226
Graph . prototype . toString = function ( ) {
227
- var graphString = "\n" ;
228
- var nodes = this . nodes ;
229
- var rowDebug , row , y , l ;
227
+ var graphString = [ ] ,
228
+ nodes = this . grid , // when using grid
229
+ rowDebug , row , y , l ;
230
230
for ( var x = 0 , len = nodes . length ; x < len ; x ++ ) {
231
- rowDebug = "" ;
231
+ rowDebug = [ ] ;
232
232
row = nodes [ x ] ;
233
233
for ( y = 0 , l = row . length ; y < l ; y ++ ) {
234
- rowDebug += row [ y ] . weight + " " ;
234
+ rowDebug . push ( row [ y ] . weight ) ;
235
235
}
236
- graphString = graphString + rowDebug + "\n" ;
236
+ graphString . push ( rowDebug . join ( " " ) ) ;
237
237
}
238
- return graphString ;
238
+ return graphString . join ( "\n" ) ;
239
239
} ;
240
240
241
241
function GridNode ( x , y , weight ) {
You can’t perform that action at this time.
0 commit comments