public int ladderLength(String start, String end, Set<String> dict) {
        if (dict == null)
            return 0;
        
        if (start.equals(end) || dict.size() <= 1)
            return 0;
        
        HashMap<String, ArrayList<String>> neighborhoodGraph = getNeighborhoodGraph(dict);
        
        HashMap<String, NodeColor> nodeColors = new HashMap<String, NodeColor>();
        for (String string : dict)
            nodeColors.put(string, NodeColor.WHITE);
            
        HashMap<String, Integer> nodeDistance = new HashMap<String, Integer>();
        nodeDistance.put(start, 0);
            
        LinkedList<String> nodeQueue = new LinkedList<String>();
        nodeQueue.add(start);
        
        String cNode;
        while ((cNode = nodeQueue.poll()) != null) {

        	nodeColors.put(cNode, NodeColor.BLACK);
            ArrayList<String> neighbors = neighborhoodGraph.get(cNode);
            
            for (String neighbor : neighbors) {
            	Integer distance = nodeDistance.get(cNode) + 1;
            	
                if (nodeColors.get(neighbor) == NodeColor.WHITE) {
                	if (neighbor.equals(end))
                		return distance;
                	
                    nodeColors.put(neighbor, NodeColor.GREY);
                    nodeDistance.put(neighbor, distance);
                    nodeQueue.add(neighbor);
                }
            }
        }
        
        return 0;
    }