Create adjacency matrix
let adj = new Array ( n + 1 ) . fill ( 0 ) . map ( ( ) => new Array ( n + 1 ) . fill ( 0 ) ) ; for ( let i = 0 ; i < edges . length ; i ++ ) { adj [ edges [ i ] [ 0 ] [ 0 ] ] [ edges [ i ] [ 0 ] [ 1 ] ] = edges [ i ] [ 1 ] ; }