]> git.lyx.org Git - features.git/commitdiff
Simplify the new graph code just a bit.
authorRichard Heck <rgheck@comcast.net>
Wed, 19 Jan 2011 14:09:44 +0000 (14:09 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 19 Jan 2011 14:09:44 +0000 (14:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37260 a592a061-630c-0410-9148-cb99ea01b6c8

src/Graph.cpp
src/Graph.h

index 874bbb7f08d6223137011db510414f57da6122a0..09db31e5f24e4d62c784e515076bf1c13ab0a632 100644 (file)
@@ -24,12 +24,13 @@ using namespace std;
 namespace lyx {
 
 
 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;
                return false;
-
-       *Q = queue<int>();
+       
+       if (!Q.empty())
+               Q = queue<int>();
 
        if (clear_visited) {
                vector<Vertex>::iterator it = vertices_.begin();
 
        if (clear_visited) {
                vector<Vertex>::iterator it = vertices_.begin();
@@ -38,7 +39,7 @@ bool Graph::bfs_init(int s, bool clear_visited, queue<int>* Q)
                        it->visited = false;
        }
        if (!vertices_[s].visited) {
                        it->visited = false;
        }
        if (!vertices_[s].visited) {
-               Q->push(s);
+               Q.push(s);
                vertices_[s].visited = true;
        }
        return true;
                vertices_[s].visited = true;
        }
        return true;
@@ -50,7 +51,7 @@ vector<int> const
 {
        vector<int> result;
        queue<int> Q;
 {
        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.
                return result;
 
        // Here's the logic, which is shared by the other routines.
@@ -86,7 +87,7 @@ vector<int> const
 {
        vector<int> result;
        queue<int> Q;
 {
        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 result;
 
        while (!Q.empty()) {
@@ -125,7 +126,7 @@ bool Graph::isReachable(int from, int to)
                return true;
 
        queue<int> Q;
                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 false;
 
        while (!Q.empty()) {
@@ -157,7 +158,7 @@ Graph::EdgePath const Graph::getPath(int from, int to)
                return EdgePath();
 
        queue<int> Q;
                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;
                return EdgePath();
 
        vector<EdgePath> pathes;
index e999f39a338a81c011aaab6917e4e514674d31b6..305cf70dcf0370ee36c7961b00966950df43c8fa 100644 (file)
@@ -46,7 +46,7 @@ public:
 
 private:
        ///
 
 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.
        /// used to recover a marked path 
        void getMarkedPath(int from, int to, EdgePath & path);
        /// these represent the arrows connecting the nodes of the graph.