14 #include <unordered_map>
44 template <
typename state,
typename action>
51 static void DFSVisit(
SearchEnvironment<state, action> &env, std::vector<
SimpleNode<state> > &thePath,
int depth, std::unordered_map<uint64_t, int, Hash64> &counts, std::unordered_map<uint64_t, double, Hash64> &aveCosts,
double gval);
55 template <
typename state,
typename action>
61 std::queue<SimpleNode<state> > myqueue;
62 std::unordered_map<uint64_t, SimpleNode<state>,
Hash64> closedlist;
64 std::vector<state> neighbors;
69 while(! myqueue.empty())
75 if (frontN.
depth >= depth)
87 for (
unsigned int x = 0; x<neighbors.size(); x++)
91 if (closedlist.find(neighborID) == closedlist.end())
96 myqueue.push(newNode);
100 closedlist[frontID] = frontN;
106 template <
typename state,
typename action>
107 void GraphCheck<state, action>::PathCountWithinRadius(
SearchEnvironment<state, action> &env, state from,
int depth, std::unordered_map<uint64_t, int, Hash64> &counts, std::unordered_map<uint64_t, double, Hash64> &aveCosts )
110 std::vector<SimpleNode<state> > thePath;
114 thePath.push_back(n0);
116 DFSVisit(env, thePath,depth,counts,aveCosts,0);
118 for (std::unordered_map<uint64_t,int, Hash64> ::iterator it = counts.begin(); it != counts.end(); it++)
121 aveCosts[it->first] /= it->second;
125 template <
typename state,
typename action>
126 void GraphCheck<state, action>::DFSVisit(
SearchEnvironment<state, action> &env, std::vector<
SimpleNode<state> > &thePath,
int depth, std::unordered_map<uint64_t, int, Hash64> &counts, std::unordered_map<uint64_t, double, Hash64> &aveCosts,
double gval)
128 std::vector<state> neighbors;
131 if (current.
depth >= depth)
136 for (
unsigned int x = 0; x<neighbors.size(); x++)
143 std::vector< SimpleNode<state> >::iterator iter;
145 for (iter = thePath.begin(); iter != thePath.end(); iter++)
161 aveCosts[uniqueID] += gval + GCost(current.
me,
neighbor);
164 thePath.push_back(sn);
165 DFSVisit(env, thePath, depth, counts, aveCosts, aveCosts[uniqueID]);