vector<int> const
Graph::getReachableTo(int target, bool clear_visited)
{
+ Mutex::Locker lock(&mutex_);
+
vector<int> result;
if (!bfs_init(target, clear_visited))
return result;
Graph::getReachable(int from, bool only_viewable,
bool clear_visited)
{
+ Mutex::Locker lock(&mutex_);
+
vector<int> result;
if (!bfs_init(from, clear_visited))
return result;
bool Graph::isReachable(int from, int to)
{
+ Mutex::Locker lock(&mutex_);
+
if (from == to)
return true;
Graph::EdgePath const Graph::getPath(int from, int to)
{
- static const EdgePath path;
+ Mutex::Locker lock(&mutex_);
+
if (from == to)
- return path;
+ return EdgePath();
if (to < 0 || !bfs_init(from))
- return path;
+ return EdgePath();
clearPaths();
while (!Q_.empty()) {
}
}
// failure
- return path;
+ return EdgePath();
}
void Graph::init(int size)
{
+ Mutex::Locker lock(&mutex_);
+
vertices_ = vector<Vertex>(size);
arrows_.clear();
numedges_ = 0;
void Graph::addEdge(int from, int to)
{
+ Mutex::Locker lock(&mutex_);
+
arrows_.push_back(Arrow(from, to, numedges_));
numedges_++;
Arrow * ar = &(arrows_.back());