Author: rgheck
Date: Wed Jan 19 15:09:44 2011
New Revision: 37260
URL: http://www.lyx.org/trac/changeset/37260
Log:
Simplify the new graph code just a bit.
Modified:
lyx-devel/trunk/src/Graph.cpp
lyx-devel/trunk/src/Graph.h
Modified: lyx-devel/trunk/src/Graph.cpp
==============================================================================
--- lyx-devel/trunk/src/Graph.cpp Wed Jan 19 12:21:34 2011 (r37259)
+++ lyx-devel/trunk/src/Graph.cpp Wed Jan 19 15:09:44 2011 (r37260)
@@ -24,12 +24,13 @@
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();
@@ -38,7 +39,7 @@
it->visited = false;
}
if (!vertices_[s].visited) {
- Q->push(s);
+ Q.push(s);
vertices_[s].visited = true;
}
return true;
@@ -50,7 +51,7 @@
{
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.
@@ -86,7 +87,7 @@
{
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()) {
@@ -125,7 +126,7 @@
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()) {
@@ -157,7 +158,7 @@
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;
Modified: lyx-devel/trunk/src/Graph.h
==============================================================================
--- lyx-devel/trunk/src/Graph.h Wed Jan 19 12:21:34 2011 (r37259)
+++ lyx-devel/trunk/src/Graph.h Wed Jan 19 15:09:44 2011 (r37260)
@@ -46,7 +46,7 @@
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.