test/dfs_test.cc
changeset 910 0fbbdd578c06
parent 877 141f9c0db4a3
parent 906 e24922c56bc2
child 966 c8fce9beb46a
equal deleted inserted replaced
9:9c1f5d27e31f 12:21980fba0311
    48   "4 5  5\n"
    48   "4 5  5\n"
    49   "5 0  6\n"
    49   "5 0  6\n"
    50   "6 3  7\n"
    50   "6 3  7\n"
    51   "@attributes\n"
    51   "@attributes\n"
    52   "source 0\n"
    52   "source 0\n"
    53   "target 5\n";
    53   "target 5\n"
       
    54   "source1 6\n"
       
    55   "target1 3\n";
       
    56 
    54 
    57 
    55 void checkDfsCompile()
    58 void checkDfsCompile()
    56 {
    59 {
    57   typedef concepts::Digraph Digraph;
    60   typedef concepts::Digraph Digraph;
    58   typedef Dfs<Digraph> DType;
    61   typedef Dfs<Digraph> DType;
   177 void checkDfs() {
   180 void checkDfs() {
   178   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   181   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   179 
   182 
   180   Digraph G;
   183   Digraph G;
   181   Node s, t;
   184   Node s, t;
       
   185   Node s1, t1;
   182 
   186 
   183   std::istringstream input(test_lgf);
   187   std::istringstream input(test_lgf);
   184   digraphReader(G, input).
   188   digraphReader(G, input).
   185     node("source", s).
   189     node("source", s).
   186     node("target", t).
   190     node("target", t).
       
   191     node("source1", s1).
       
   192     node("target1", t1).
   187     run();
   193     run();
   188 
   194 
   189   Dfs<Digraph> dfs_test(G);
   195   Dfs<Digraph> dfs_test(G);
   190   dfs_test.run(s);
   196   dfs_test.run(s);
   191 
   197 
   208       }
   214       }
   209     }
   215     }
   210   }
   216   }
   211 
   217 
   212   {
   218   {
       
   219   Dfs<Digraph> dfs(G);
       
   220   check(dfs.run(s1,t1) && dfs.reached(t1),"Node 3 is reachable from Node 6.");
       
   221   }
       
   222   
       
   223   {
   213     NullMap<Node,Arc> myPredMap;
   224     NullMap<Node,Arc> myPredMap;
   214     dfs(G).predMap(myPredMap).run(s);
   225     dfs(G).predMap(myPredMap).run(s);
   215   }
   226   }
   216 }
   227 }
   217 
   228