test/dfs_test.cc
changeset 281 e9b4fbe163f5
parent 228 b6732e0d38c5
child 286 da414906fe21
equal deleted inserted replaced
3:29ca48641626 4:601fe879bbad
    18 
    18 
    19 #include <lemon/concepts/digraph.h>
    19 #include <lemon/concepts/digraph.h>
    20 #include <lemon/smart_graph.h>
    20 #include <lemon/smart_graph.h>
    21 #include <lemon/list_graph.h>
    21 #include <lemon/list_graph.h>
    22 #include <lemon/lgf_reader.h>
    22 #include <lemon/lgf_reader.h>
    23 
       
    24 #include <lemon/dfs.h>
    23 #include <lemon/dfs.h>
    25 #include <lemon/path.h>
    24 #include <lemon/path.h>
    26 
    25 
    27 #include "graph_test.h"
    26 #include "graph_test.h"
    28 #include "test_tools.h"
    27 #include "test_tools.h"
    86   typedef concepts::Digraph Digraph;
    85   typedef concepts::Digraph Digraph;
    87   typedef Digraph::Arc Arc;
    86   typedef Digraph::Arc Arc;
    88   typedef Digraph::Node Node;
    87   typedef Digraph::Node Node;
    89 
    88 
    90   Digraph g;
    89   Digraph g;
    91   dfs(g,Node()).run();
    90   bool b;
    92   dfs(g).source(Node()).run();
    91   dfs(g).run(Node());
       
    92   b=dfs(g).run(Node(),Node());
       
    93   dfs(g).run();
    93   dfs(g)
    94   dfs(g)
    94     .predMap(concepts::WriteMap<Node,Arc>())
    95     .predMap(concepts::ReadWriteMap<Node,Arc>())
    95     .distMap(concepts::WriteMap<Node,VType>())
    96     .distMap(concepts::ReadWriteMap<Node,VType>())
    96     .reachedMap(concepts::ReadWriteMap<Node,bool>())
    97     .reachedMap(concepts::ReadWriteMap<Node,bool>())
    97     .processedMap(concepts::WriteMap<Node,bool>())
    98     .processedMap(concepts::WriteMap<Node,bool>())
    98     .run(Node());
    99     .run(Node());
       
   100   b=dfs(g)
       
   101     .predMap(concepts::ReadWriteMap<Node,Arc>())
       
   102     .distMap(concepts::ReadWriteMap<Node,VType>())
       
   103     .reachedMap(concepts::ReadWriteMap<Node,bool>())
       
   104     .processedMap(concepts::WriteMap<Node,bool>())
       
   105     .path(concepts::Path<Digraph>())
       
   106     .dist(VType())
       
   107     .run(Node(),Node());
       
   108   dfs(g)
       
   109     .predMap(concepts::ReadWriteMap<Node,Arc>())
       
   110     .distMap(concepts::ReadWriteMap<Node,VType>())
       
   111     .reachedMap(concepts::ReadWriteMap<Node,bool>())
       
   112     .processedMap(concepts::WriteMap<Node,bool>())
       
   113     .run();
    99 }
   114 }
   100 
   115 
   101 template <class Digraph>
   116 template <class Digraph>
   102 void checkDfs() {
   117 void checkDfs() {
   103   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   118   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   127         Arc e=dfs_test.predArc(v);
   142         Arc e=dfs_test.predArc(v);
   128         Node u=G.source(e);
   143         Node u=G.source(e);
   129         check(u==dfs_test.predNode(v),"Wrong tree.");
   144         check(u==dfs_test.predNode(v),"Wrong tree.");
   130         check(dfs_test.dist(v) - dfs_test.dist(u) == 1,
   145         check(dfs_test.dist(v) - dfs_test.dist(u) == 1,
   131               "Wrong distance. (" << dfs_test.dist(u) << "->"
   146               "Wrong distance. (" << dfs_test.dist(u) << "->"
   132               <<dfs_test.dist(v) << ')');
   147               << dfs_test.dist(v) << ")");
   133       }
   148       }
   134     }
   149     }
       
   150   }
       
   151 
       
   152   {
       
   153     NullMap<Node,Arc> myPredMap;
       
   154     dfs(G).predMap(myPredMap).run(s);
   135   }
   155   }
   136 }
   156 }
   137 
   157 
   138 int main()
   158 int main()
   139 {
   159 {