test/dfs_test.cc
changeset 785 8d281761dea4
parent 577 65fbcf2f978a
parent 737 e24922c56bc2
child 761 f1398882a928
child 796 7e368d9b67f7
equal deleted inserted replaced
8:49fb9d42927c 10:c1349bb7192e
    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