Create a graph where node numbers are indexes in pset [ ] and there is an edge between two nodes only if they differ by single digit .
graph g ( pset . size ( ) ) ; for ( int i = 0 ; i < pset . size ( ) ; i ++ ) for ( int j = i + 1 ; j < pset . size ( ) ; j ++ ) if ( compare ( pset [ i ] , pset [ j ] ) ) g . addedge ( i , j ) ;