To store edges with weight '1'
let mp2 = new Array ( n + 1 ) . fill ( [ ] ) ; for ( let i = 1 ; i <= n ; i ++ ) { for ( let j = 1 ; j <= n ; j ++ ) { if ( i == j ) { continue ; } if ( adj [ i ] [ j ] == ' ' ) { mp1 [ i ] . push ( j ) ; } else { mp2 [ i ] . push ( j ) ; } } }