namespace lyx {
-bool Graph::bfs_init(int s, bool clear_visited, queue<int>* Q)
+bool Graph::bfs_init(int s, bool clear_visited, queue<int> & Q)
{
- if (s < 0 || !Q)
+ if (s < 0)
return false;
-
- *Q = queue<int>();
+
+ if (!Q.empty())
+ Q = queue<int>();
if (clear_visited) {
vector<Vertex>::iterator it = vertices_.begin();
it->visited = false;
}
if (!vertices_[s].visited) {
- Q->push(s);
+ Q.push(s);
vertices_[s].visited = true;
}
return true;
{
vector<int> result;
queue<int> Q;
- if (!bfs_init(target, clear_visited, &Q))
+ if (!bfs_init(target, clear_visited, Q))
return result;
// Here's the logic, which is shared by the other routines.
{
vector<int> result;
queue<int> Q;
- if (!bfs_init(from, clear_visited, &Q))
+ if (!bfs_init(from, clear_visited, Q))
return result;
while (!Q.empty()) {
return true;
queue<int> Q;
- if (to < 0 || !bfs_init(from, true, &Q))
+ if (to < 0 || !bfs_init(from, true, Q))
return false;
while (!Q.empty()) {
return EdgePath();
queue<int> Q;
- if (to < 0 || !bfs_init(from, true, &Q))
+ if (to < 0 || !bfs_init(from, true, Q))
return EdgePath();
vector<EdgePath> pathes;
private:
///
- bool bfs_init(int, bool clear_visited, std::queue<int>* Q);
+ bool bfs_init(int, bool clear_visited, std::queue<int> & Q);
/// used to recover a marked path
void getMarkedPath(int from, int to, EdgePath & path);
/// these represent the arrows connecting the nodes of the graph.