- Add compilation tests for the function type interface of BFS/DFS/Dijkstra
authoralpar
Wed, 16 Mar 2005 16:40:21 +0000
changeset 122020b26ee5812b
parent 1219 ce885274b754
child 1221 6706c788ebb5
- Add compilation tests for the function type interface of BFS/DFS/Dijkstra
- Fix the bugs covered up by these tests
src/lemon/dfs.h
src/lemon/dijkstra.h
src/test/bfs_test.cc
src/test/dfs_test.cc
src/test/dijkstra_test.cc
     1.1 --- a/src/lemon/dfs.h	Wed Mar 16 13:25:19 2005 +0000
     1.2 +++ b/src/lemon/dfs.h	Wed Mar 16 16:40:21 2005 +0000
     1.3 @@ -431,6 +431,40 @@
     1.4        return *this;
     1.5      }
     1.6  
     1.7 +    ///Sets the map indicating if a node is reached.
     1.8 +
     1.9 +    ///Sets the map indicating if a node is reached.
    1.10 +    ///If you don't use this function before calling \ref run(),
    1.11 +    ///it will allocate one. The destuctor deallocates this
    1.12 +    ///automatically allocated map, of course.
    1.13 +    ///\return <tt> (*this) </tt>
    1.14 +    Dfs &reachedMap(ReachedMap &m) 
    1.15 +    {
    1.16 +      if(local_reached) {
    1.17 +	delete _reached;
    1.18 +	local_reached=false;
    1.19 +      }
    1.20 +      _reached = &m;
    1.21 +      return *this;
    1.22 +    }
    1.23 +
    1.24 +    ///Sets the map indicating if a node is processed.
    1.25 +
    1.26 +    ///Sets the map indicating if a node is processed.
    1.27 +    ///If you don't use this function before calling \ref run(),
    1.28 +    ///it will allocate one. The destuctor deallocates this
    1.29 +    ///automatically allocated map, of course.
    1.30 +    ///\return <tt> (*this) </tt>
    1.31 +    Dfs &processedMap(ProcessedMap &m) 
    1.32 +    {
    1.33 +      if(local_processed) {
    1.34 +	delete _processed;
    1.35 +	local_processed=false;
    1.36 +      }
    1.37 +      _processed = &m;
    1.38 +      return *this;
    1.39 +    }
    1.40 +
    1.41    public:
    1.42      ///\name Execution control
    1.43      ///The simplest way to execute the algorithm is to use
     2.1 --- a/src/lemon/dijkstra.h	Wed Mar 16 13:25:19 2005 +0000
     2.2 +++ b/src/lemon/dijkstra.h	Wed Mar 16 16:40:21 2005 +0000
     2.3 @@ -807,6 +807,7 @@
     2.4    ///as well as the \ref Dijkstra class.
     2.5    /// The \ref DijkstraWizardBase is a class to be the default traits of the
     2.6    /// \ref DijkstraWizard class.
     2.7 +  /// \todo More named parameters are required...
     2.8    template<class GR,class LM>
     2.9    class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,LM>
    2.10    {
     3.1 --- a/src/test/bfs_test.cc	Wed Mar 16 13:25:19 2005 +0000
     3.2 +++ b/src/test/bfs_test.cc	Wed Mar 16 16:40:21 2005 +0000
     3.3 @@ -58,6 +58,28 @@
     3.4  
     3.5  }
     3.6  
     3.7 +void check_Bfs_Function_Compile() 
     3.8 +{
     3.9 +  typedef int VType;
    3.10 +  typedef concept::StaticGraph Graph;
    3.11 +
    3.12 +  typedef Graph::Edge Edge;
    3.13 +  typedef Graph::Node Node;
    3.14 +  typedef Graph::EdgeIt EdgeIt;
    3.15 +  typedef Graph::NodeIt NodeIt;
    3.16 +  typedef concept::ReadMap<Edge,VType> LengthMap;
    3.17 +   
    3.18 +  bfs(Graph(),Node()).run();
    3.19 +  bfs(Graph()).source(Node()).run();
    3.20 +  bfs(Graph())
    3.21 +    .predMap(concept::WriteMap<Node,Edge>())
    3.22 +    .distMap(concept::WriteMap<Node,VType>())
    3.23 +    .reachedMap(concept::ReadWriteMap<Node,bool>())
    3.24 +    .processedMap(concept::WriteMap<Node,bool>())
    3.25 +    .run(Node());
    3.26 +  
    3.27 +}
    3.28 +
    3.29  int main()
    3.30  {
    3.31      
     4.1 --- a/src/test/dfs_test.cc	Wed Mar 16 13:25:19 2005 +0000
     4.2 +++ b/src/test/dfs_test.cc	Wed Mar 16 16:40:21 2005 +0000
     4.3 @@ -58,6 +58,29 @@
     4.4  
     4.5  }
     4.6  
     4.7 +
     4.8 +void check_Dfs_Function_Compile() 
     4.9 +{
    4.10 +  typedef int VType;
    4.11 +  typedef concept::StaticGraph Graph;
    4.12 +
    4.13 +  typedef Graph::Edge Edge;
    4.14 +  typedef Graph::Node Node;
    4.15 +  typedef Graph::EdgeIt EdgeIt;
    4.16 +  typedef Graph::NodeIt NodeIt;
    4.17 +  typedef concept::ReadMap<Edge,VType> LengthMap;
    4.18 +   
    4.19 +  dfs(Graph(),Node()).run();
    4.20 +  dfs(Graph()).source(Node()).run();
    4.21 +  dfs(Graph())
    4.22 +    .predMap(concept::WriteMap<Node,Edge>())
    4.23 +    .distMap(concept::WriteMap<Node,VType>())
    4.24 +    .reachedMap(concept::ReadWriteMap<Node,bool>())
    4.25 +    .processedMap(concept::WriteMap<Node,bool>())
    4.26 +    .run(Node());
    4.27 +  
    4.28 +}
    4.29 +
    4.30  int main()
    4.31  {
    4.32      
     5.1 --- a/src/test/dijkstra_test.cc	Wed Mar 16 13:25:19 2005 +0000
     5.2 +++ b/src/test/dijkstra_test.cc	Wed Mar 16 16:40:21 2005 +0000
     5.3 @@ -62,6 +62,27 @@
     5.4    
     5.5  }
     5.6  
     5.7 +void check_Dijkstra_Function_Compile() 
     5.8 +{
     5.9 +  typedef int VType;
    5.10 +  typedef concept::StaticGraph Graph;
    5.11 +
    5.12 +  typedef Graph::Edge Edge;
    5.13 +  typedef Graph::Node Node;
    5.14 +  typedef Graph::EdgeIt EdgeIt;
    5.15 +  typedef Graph::NodeIt NodeIt;
    5.16 +  typedef concept::ReadMap<Edge,VType> LengthMap;
    5.17 +   
    5.18 +  dijkstra(Graph(),LengthMap(),Node()).run();
    5.19 +  dijkstra(Graph(),LengthMap()).source(Node()).run();
    5.20 +  dijkstra(Graph(),LengthMap())
    5.21 +    .predMap(concept::WriteMap<Node,Edge>())
    5.22 +    .distMap(concept::WriteMap<Node,VType>())
    5.23 +    .run(Node());
    5.24 +  
    5.25 +}
    5.26 +
    5.27 +
    5.28  int main()
    5.29  {
    5.30