@@ -121,15 +121,15 @@ export default {
121
121
122
122
chunker . add (
123
123
8 ,
124
- ( vis , x , y , z , a , b ) => {
124
+ ( vis , x , y ) => {
125
125
vis . array . set ( x , 'BFS' ) ;
126
126
vis . array . setList ( y ) ;
127
127
128
128
// select start node in blue
129
- vis . array . select ( 0 , b + 1 ) ;
130
- vis . graph . colorNode ( b , colors . FRONTIER_N ) ;
129
+ vis . array . select ( 0 , s + 1 , 0 , s + 1 , colors . FRONTIER_A ) ;
130
+ vis . graph . colorNode ( s , colors . FRONTIER_N ) ;
131
131
} ,
132
- [ [ displayedNodes , displayedParent , displayedVisited ] , displayedQueue , explored , visited , s , Nodes ]
132
+ [ [ displayedNodes , displayedParent , displayedVisited ] , displayedQueue ]
133
133
) ;
134
134
135
135
// Nodes <- queue containing just s B9
@@ -148,7 +148,7 @@ export default {
148
148
) ;
149
149
150
150
// while Nodes not empty B2
151
- // XXX ?nice to have while true and break out of the
151
+ // ?nice to have while true and break out of the
152
152
// loop after the chunk (conditionally) so when the loop exits
153
153
// we have an extra chunk at the start of the loop
154
154
// while (Nodes.length > 0) {
@@ -175,17 +175,16 @@ export default {
175
175
176
176
// remove the highlight between n
177
177
// and the last visited neighbor
178
- if ( ( c_n != null ) && ( c_lastNei != null ) ) {
179
-
180
- vis . graph . removeEdgeColor ( c_n , c_lastNei ) ;
181
- let prevColor ;
182
- if ( c_Nodes . includes ( c_lastNei ) )
183
- prevColor = colors . FRONTIER_E ;
184
- else
185
- prevColor = colors . FINALISED_E ;
178
+ if ( ( c_n != null ) && ( c_lastNei != null ) ) {
186
179
vis . graph . removeEdgeColor ( c_n , c_lastNei ) ;
187
- vis . graph . colorEdge ( c_n , c_lastNei , prevColor ) ;
188
- }
180
+ if ( ( c_n != null ) && ( c_lastNei != null ) ) {
181
+ vis . graph . removeEdgeColor ( c_n , c_lastNei ) ;
182
+ if ( c_parent [ c_lastNei ] === c_n )
183
+ vis . graph . colorEdge ( c_n , c_lastNei , colors . FRONTIER_E ) ;
184
+ else if ( c_parent [ c_n ] === c_lastNei )
185
+ vis . graph . colorEdge ( c_n , c_lastNei , colors . FINALISED_E ) ;
186
+ }
187
+ }
189
188
} ,
190
189
[ n , lastNeighbor , parent , visited , Nodes ]
191
190
) ;
@@ -225,7 +224,7 @@ export default {
225
224
226
225
// finalise edge color to n from parent
227
226
if ( c_parent [ c_n ] !== null ) {
228
- vis . graph . removeEdgeColor ( c_n , c_parent [ c_n ] ) ;
227
+ vis . graph . removeEdgeColor ( c_n , c_parent [ c_n ] ) ;
229
228
vis . graph . colorEdge ( c_n , c_parent [ c_n ] , colors . FINALISED_E ) ;
230
229
}
231
230
@@ -302,23 +301,14 @@ export default {
302
301
chunker . add (
303
302
4 ,
304
303
( vis , c_n , c_m , c_lastNei , c_parent , c_visited , c_Nodes ) => {
305
- //remove the color on Edge connecting the last neighbor
306
-
307
-
308
-
309
- //remove the orange highlight from the edge connecting the last neighbour
310
- if ( c_lastNei != null )
311
- {
304
+ // remove the highlight between n
305
+ // and the last visited neighbor
306
+ if ( ( c_n != null ) && ( c_lastNei != null ) ) {
312
307
vis . graph . removeEdgeColor ( c_n , c_lastNei ) ;
313
-
314
- // recolor if node has a parent or is start
315
- if ( c_parent [ c_lastNei ] != null || c_lastNei == start ) {
316
- vis . graph . removeEdgeColor ( c_n , c_lastNei ) ;
317
- if ( c_parent [ c_n ] === c_lastNei )
318
- vis . graph . colorEdge ( c_n , c_lastNei , colors . FINALISED_E ) ;
319
- else if ( c_parent [ c_lastNei ] === c_n )
320
- vis . graph . colorEdge ( c_n , c_lastNei , colors . FRONTIER_E ) ;
321
- }
308
+ if ( c_parent [ c_n ] === c_lastNei )
309
+ vis . graph . colorEdge ( c_n , c_lastNei , colors . FINALISED_E ) ;
310
+ else if ( c_parent [ c_lastNei ] === c_n )
311
+ vis . graph . colorEdge ( c_n , c_lastNei , colors . FRONTIER_E ) ;
322
312
}
323
313
324
314
//highlight the edge connecting the neighbor
@@ -486,17 +476,16 @@ export default {
486
476
487
477
// remove the highlight between n
488
478
// and the last visited neighbor
489
- if ( ( c_n != null ) && ( c_lastNei != null ) ) {
490
-
491
- vis . graph . removeEdgeColor ( c_n , c_lastNei ) ;
492
- let prevColor ;
493
- if ( c_Nodes . includes ( c_lastNei ) )
494
- prevColor = colors . FRONTIER_E ;
495
- else
496
- prevColor = colors . FINALISED_E ;
479
+ if ( ( c_n != null ) && ( c_lastNei != null ) ) {
497
480
vis . graph . removeEdgeColor ( c_n , c_lastNei ) ;
498
- vis . graph . colorEdge ( c_n , c_lastNei , prevColor ) ;
499
- }
481
+ if ( ( c_n != null ) && ( c_lastNei != null ) ) {
482
+ vis . graph . removeEdgeColor ( c_n , c_lastNei ) ;
483
+ if ( c_parent [ c_lastNei ] === c_n )
484
+ vis . graph . colorEdge ( c_n , c_lastNei , colors . FRONTIER_E ) ;
485
+ else if ( c_parent [ c_n ] === c_lastNei )
486
+ vis . graph . colorEdge ( c_n , c_lastNei , colors . FINALISED_E ) ;
487
+ }
488
+ }
500
489
} ,
501
490
[ n , lastNeighbor , parent , visited , Nodes ]
502
491
) ;
0 commit comments