src/spelling/WPTree.java
// see method description in WordPath interface
see method description in WordPath interface
see method description in WordPath interface
public List<String> findPath(String word1, String word2) 
	{
		LinkedList<WPTreeNode> queue = new LinkedList<WPTreeNode>();
		Set<String> visitedWord = new HashSet<String>();
		WPTreeNode rootNode = new WPTreeNode(word1, null);
		this.root=rootNode;
		visitedWord.add(word1);
		queue.add(rootNode);
		WPTreeNode current = null;
		WPTreeNode childNode=null;
		List<String> neighbors=null;
		boolean word2Found = false;
		System.out.println(" word1 ="+word1);
		while(!queue.isEmpty() && !word2Found){
			current=queue.remove();
			System.out.println(" current = "+current.getWord());
			neighbors = this.nw.distanceOne(current.getWord(), true);
			for (String string : neighbors) {
				if(!visitedWord.contains(string)){
					childNode =current.addChild(string);
					visitedWord.add(string);
					queue.add(childNode);
					if(childNode.getWord().equalsIgnoreCase(word2)){
							word2Found=true;
							return childNode.buildPathToRoot();
					}
				}
			}
		}
	    return null;
	}
public List < String > findPath ( String word1 , String word2 ) { LinkedList < WPTreeNode > queue = new LinkedList < WPTreeNode > ( ) ; Set < String > visitedWord = new HashSet < String > ( ) ; WPTreeNode rootNode = new WPTreeNode ( word1 , null ) ; this . root = rootNode ; visitedWord . add ( word1 ) ; queue . add ( rootNode ) ; WPTreeNode current = null ; WPTreeNode childNode = null ; List < String > neighbors = null ; boolean word2Found = false ; System . out . println ( " word1 =" + word1 ) ; while ( ! queue . isEmpty ( ) && ! word2Found ) { current = queue . remove ( ) ; System . out . println ( " current = " + current . getWord ( ) ) ; neighbors = this . nw . distanceOne ( current . getWord ( ) , true ) ; for ( String string : neighbors ) { if ( ! visitedWord . contains ( string ) ) { childNode = current . addChild ( string ) ; visitedWord . add ( string ) ; queue . add ( childNode ) ; if ( childNode . getWord ( ) . equalsIgnoreCase ( word2 ) ) { word2Found = true ; return childNode . buildPathToRoot ( ) ; } } } } return null ; }
see method description in WordPath interface
see method description in WordPath interface