private static int findOther ( int [ ] vs , int u , int x ) { for ( int v : vs ) { if ( v != u && v != x ) return v ; } throw new IllegalArgumentException ( "vs[] did not contain another vertex" ) ; }
Finds a vertex in vs which is not u or x . .