HOG2
AbstractionSearchEnvironment.cpp
Go to the documentation of this file.
1 /*
2  * AbstractionSearchEnvironment.cpp
3  * hog
4  *
5  * Created by Nathan Sturtevant on 4/5/07.
6  * Copyright 2007 Nathan Sturtevant, University of Alberta. All rights reserved.
7  *
8  */
9 
11 
12 
13 void AbstractionSearchEnvironment::getNeighbors(uint32_t nodeID, std::vector<uint32_t> &neighbors)
14 {
16  node *n1 = g->GetNode(nodeID);
18  for (int next = n1->nodeNeighborNext(ni); next != -1; next = n1->nodeNeighborNext(ni))
19  {
20  neighbors.push_back(next);
21  }
22 }
23 
24 double AbstractionSearchEnvironment::heuristic(uint32_t node1, uint32_t node2)
25 {
27  node *n1 = g->GetNode(node1);
28  node *n2 = g->GetNode(node2);
29  edge *e = g->FindEdge(node1, node2);
30  if (e)
31  return e->GetWeight();
32  return ga->h(n1, n2);
33 }
34 
35 double AbstractionSearchEnvironment::gcost(uint32_t node1, uint32_t node2)
36 {
37  return heuristic(node1, node2);
38 }
edge::GetWeight
double GetWeight()
Definition: Graph.h:140
Graph::FindEdge
edge * FindEdge(unsigned int from, unsigned int to)
Finds an edge between nodes with ids from and to, no matter which direction.
Definition: Graph.cpp:230
neighbor_iterator
unsigned int neighbor_iterator
Definition: Graph.h:34
GraphAbstraction::GetAbstractGraph
Graph * GetAbstractGraph(int level)
return the abstract Graph at the given level
Definition: GraphAbstraction.h:74
Graph
A generic Graph class.
Definition: Graph.h:66
Graph::GetNode
node * GetNode(unsigned long num)
Definition: Graph.cpp:152
AbstractionSearchEnvironment.h
GraphAbstraction::h
virtual double h(node *a, node *b)=0
heuristic cost between any two nodes
AbstractionSearchEnvironment::level
int level
Definition: AbstractionSearchEnvironment.h:27
AbstractionSearchEnvironment::ga
GraphAbstraction * ga
Definition: AbstractionSearchEnvironment.h:26
AbstractionSearchEnvironment::heuristic
double heuristic(uint32_t node1, uint32_t node2)
Definition: AbstractionSearchEnvironment.cpp:24
node::nodeNeighborNext
int nodeNeighborNext(neighbor_iterator &) const
Definition: Graph.cpp:807
AbstractionSearchEnvironment::gcost
double gcost(uint32_t node1, uint32_t node2)
Definition: AbstractionSearchEnvironment.cpp:35
AbstractionSearchEnvironment::getNeighbors
void getNeighbors(uint32_t nodeID, std::vector< uint32_t > &neighbors)
Definition: AbstractionSearchEnvironment.cpp:13
node::getNeighborIter
neighbor_iterator getNeighborIter() const
Definition: Graph.cpp:802
node
Nodes to be stored within a Graph.
Definition: Graph.h:170
edge
Edge class for connections between node in a Graph.
Definition: Graph.h:129