00001 #ifndef _ASTAR_H_ 00002 #define _ASTAR_H_ 00003 00004 #include "graph.h" 00005 #include <set> 00006 #include <vector> 00007 00008 namespace Graph 00009 { 00010 00011 //============================================================================= 00012 // class Astar 00013 // 00014 // This is the class for doing astar graph searches 00015 // 00016 //============================================================================= 00017 class Astar 00018 { 00019 public: 00020 std::vector< int > GetPath() const; 00021 void Search( const GraphBase& g, const int start, const int end ); 00022 protected: 00023 void AddToOpenList( const int nodeNumber ); 00024 double GetCost( const int nodeNumber ); 00025 int GetNodeFromOpenList() const; 00026 void MarkNodeCost( const int nodeNumber, const double cost ); 00027 bool OpenListIsEmpty() const; 00028 void ProcessAllNeighborsOfNode( const GraphBase& g, const int node ); 00029 void RemoveNodeFromOpenList( const int nodeNum ); 00030 int SmallestNeighbor( const GraphBase& g, const int node ); 00031 private: 00032 std::set< int > m_OpenList; 00033 std::vector< double > m_Costs; 00034 std::vector< int > m_Path; 00035 }; 00036 00037 00038 //----------------------------------------------------------------------------- 00039 } //namespace Graph 00040 #endif