@@ -0,0 +1,2157 @@
+package com.cafeform.algorithm;%0A%0Aimport java.util.*;%0Aimport java.util.concurrent.LinkedBlockingDeque;%0Aimport javax.annotation.PreDestroy;%0A%0A/**%0A * Another implementation of bredth first search.%0A * Uses color and predecesser HashMap to check the status of each node%0A *  color : Back=Found, Gray=Found, but not child search, White=Not found%0A *  predeccessor : parent node%0A * %0A * @author kaizawa%0A */%0Aclass BreadthFirstSearch2 extends SearchAlgorithm %7B%0A    LinkedBlockingDeque%3CNode%3E foundNodeQueue = new LinkedBlockingDeque%3C%3E();%0A    HashMap%3CNode, Color%3E colorMap = new HashMap%3C%3E();%0A    HashMap%3CNode, Node%3E predeccessorMap = new HashMap(); %0A    %0A    enum Color %7BBLACK, WHITE, GRAY%7D;%0A%0A    public BreadthFirstSearch2(Node startNode, Node goalNode) %7B%0A        super(startNode, goalNode);%0A    %7D%0A    %0A    @Override%0A    public SearchResult doSearch() %7B%0A        predeccessorMap.put(startNode, null);%0A        foundNodeQueue.add(startNode);%0A            %0A        while(false == foundNodeQueue.isEmpty())%7B%0A            Node currentNode = foundNodeQueue.poll();%0A%0A            if (currentNode == goalNode) %7B%0A                break;%0A            %7D else %7B%0A                for (Node child : (Set%3CNode%3E) currentNode.getChildrenMap().keySet()) %7B%0A                    //Check if it has already been found%0A                    if(colorMap.containsKey(child))%7B%0A                        // This node has ever been found.%0A                        continue;%0A                    %7D%0A%0A                    // Put child node to the gray queue.%0A                    foundNodeQueue.add(child);%0A                    // Set currentNode as parent of child node%0A                    predeccessorMap.put(child, currentNode);%0A                    // Set color of child node to GRAY%0A                    colorMap.put(child, Color.GRAY);%0A                %7D%0A            %7D%0A        %7D %0A%0A        ArrayList%3CNode%3E shortestPath = new ArrayList%3C%3E();%0A        %0A        for(Node node = goalNode; null != node; node = predeccessorMap.get(node))%7B%0A            shortestPath.add(0, node);%0A        %7D%0A        %0A        // Return path which found first        %0A        return new SearchResult(shortestPath, %22BreadthFirstSearch2%22);%0A    %7D%0A%7D%0A

add another implementation of breadth first search algorithm