1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#ifndef PATH_H_
#define PATH_H_
#include <string>
#include <sstream>
#include <climits>
#include <deque>
#include <cassert>
enum PathSearchResult {
FOUND_PATH = 0,
TOO_MANY_PATHS,
TOO_MANY_BRANCHES,
PATH_CONTAINS_CYCLE,
MAX_COST_EXCEEDED,
EXCEEDED_MEM_LIMIT,
NO_PATH
};
const char* PathSearchResultLabel[] = {
"FOUND_PATH",
"TOO_MANY_PATHS",
"TOO_MANY_BRANCHES",
"PATH_CONTAINS_CYCLE",
"MAX_COST_EXCEEDED",
"EXCEEDED_MEM_LIMIT",
"NO_PATH"
};
enum Direction { FORWARD = 0, REVERSE };
inline static const char* directionStr(Direction dir)
{
switch(dir) {
case FORWARD:
return "FORWARD";
case REVERSE:
return "REVERSE";
default:
assert(false);
}
}
const unsigned NO_LIMIT = UINT_MAX;
template <class Vertex> class Path : public std::deque<Vertex>
{
public:
std::string str() {
std::stringstream s;
typename std::deque<Vertex>::iterator i = this->begin();
for (; i != this->end(); i++) {
if (i != this->begin())
s << ",";
s << *i;
}
return s.str();
}
};
#endif
|