Create adjacency matrix
vector < vector < char > > adj ( n + 1 , vector < char > ( n + 1 ) ) ; for ( int i = 0 ; i < edges . size ( ) ; i ++ ) { adj [ edges [ i ] . first . first ] [ edges [ i ] . first . second ] = edges [ i ] . second ; }