If only 1 edge is required
if ( ( adj [ i ] [ j ] == 1 && adj [ j ] [ k ] == 1 ) || ( adj [ j ] [ k ] == 1 && adj [ k ] [ i ] == 1 ) || ( adj [ k ] [ i ] == 1 && adj [ i ] [ j ] == 1 ) ) { edgesNeeded = 1 ; }