test/dfs_test.cc
changeset 1072 3dcb45a871c3
parent 293 47fbc814aa31
child 1009 c85f53572941
child 1010 1861d5dcf312
child 1078 c59bdcc8e33e
equal deleted inserted replaced
6:aafd3da7d5f9 10:c3f2cda538b9
    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;
   142 void checkDfs() {
   145 void checkDfs() {
   143   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   146   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   144 
   147 
   145   Digraph G;
   148   Digraph G;
   146   Node s, t;
   149   Node s, t;
       
   150   Node s1, t1;
   147 
   151 
   148   std::istringstream input(test_lgf);
   152   std::istringstream input(test_lgf);
   149   digraphReader(G, input).
   153   digraphReader(G, input).
   150     node("source", s).
   154     node("source", s).
   151     node("target", t).
   155     node("target", t).
       
   156     node("source1", s1).
       
   157     node("target1", t1).
   152     run();
   158     run();
   153 
   159 
   154   Dfs<Digraph> dfs_test(G);
   160   Dfs<Digraph> dfs_test(G);
   155   dfs_test.run(s);
   161   dfs_test.run(s);
   156 
   162 
   173       }
   179       }
   174     }
   180     }
   175   }
   181   }
   176 
   182 
   177   {
   183   {
       
   184   Dfs<Digraph> dfs(G);
       
   185   check(dfs.run(s1,t1) && dfs.reached(t1),"Node 3 is reachable from Node 6.");
       
   186   }
       
   187   
       
   188   {
   178     NullMap<Node,Arc> myPredMap;
   189     NullMap<Node,Arc> myPredMap;
   179     dfs(G).predMap(myPredMap).run(s);
   190     dfs(G).predMap(myPredMap).run(s);
   180   }
   191   }
   181 }
   192 }
   182 
   193