001 package aima.search.uninformed; 002 003 import java.util.Comparator; 004 005 import aima.search.framework.Node; 006 import aima.search.framework.PrioritySearch; 007 import aima.search.framework.Problem; 008 import aima.search.framework.QueueSearch; 009 010 /** 011 * Artificial Intelligence A Modern Approach (2nd Edition): page 75. 012 * 013 * Uniform-cost search. 014 */ 015 016 /** 017 * @author Ciaran O'Reilly 018 * 019 */ 020 public class UniformCostSearch extends PrioritySearch { 021 022 public UniformCostSearch(QueueSearch search) { 023 this.search = search; 024 } 025 026 // 027 // PROTECTED METHODS 028 // 029 @Override 030 protected Comparator<Node> getComparator(Problem p) { 031 return new Comparator<Node>() { 032 public int compare(Node node1, Node node2) { 033 return (new Double(node1.getPathCost()).compareTo(new Double( 034 node2.getPathCost()))); 035 } 036 }; 037 } 038 }