To find adjacent words that are the same length, and differ in only one
character, use the following algorithm:
for( Map.Entry<Integer,Set<String>> e : theMap.entrySet( ) )
{
int theWordLen = e.getKey( );
Set<String> theWords = e.getValues( );
for( int i = 0; i < theWordLen; i++ )
{
// CREATE AN EMPTY MAP, key is String, value is List of String
// such that the key represents all the strings in its corresponding
// value with character at position i removed
Map<String,List<String>> repMap = new TreeMap<String,List<String>>( );
for( String w : theWords )
{
String shorter = removeOneChar( s, i );
UPDATE repMap with shorter and w
}
FIND cliques of words (lists with length more than 1 in repMap) that are
identical except for position i and ADD EDGES
}
}