COIN-OR::LEMON - Graph Library

Changeset 944:4f064aff855e in lemon-0.x for src/work/marci/bfs_mm_test.cc


Ignore:
Timestamp:
10/16/04 02:20:13 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1293
Message:

It's time to design an iterable generic bfs

File:
1 copied

Legend:

Unmodified
Added
Removed
  • src/work/marci/bfs_mm_test.cc

    r921 r944  
    1515 */
    1616
    17 #include "test_tools.h"
     17#include <test/test_tools.h>
    1818#include <lemon/smart_graph.h>
    19 #include <lemon/bfs.h>
    20 #include<lemon/skeletons/graph.h>
     19#include <bfs_mm.h>
     20#include <lemon/skeletons/graph.h>
    2121
    2222using namespace lemon;
     
    3434  typedef Graph::NodeIt NodeIt;
    3535 
    36   typedef Bfs<Graph> BType;
     36  typedef marci::Bfs<Graph> BType;
    3737 
    3838  Graph G;
     
    4444  BType::PredMap p(G);
    4545  BType::PredNodeMap pn(G);
    46  
    47   BType bfs_test(G);
     46
     47   Graph::NodeMap<bool> reached(G);
     48   Graph::NodeMap<Edge> pred(G);
     49   Graph::NodeMap<Node> pred_node(G);
     50   Graph::NodeMap<int> dist(G); 
     51   BType bfs_test(G, reached, pred, pred_node, dist);
    4852 
    4953  bfs_test.run(n);
     
    7781  t=ps.inner[0];
    7882 
    79   Bfs<Graph> bfs_test(G);
     83   Graph::NodeMap<bool> reached(G);
     84   Graph::NodeMap<Edge> pred(G);
     85   Graph::NodeMap<Node> pred_node(G);
     86   Graph::NodeMap<int> dist(G);
     87   marci::Bfs<Graph> bfs_test(G, reached, pred, pred_node, dist);
    8088  bfs_test.run(s);
    8189 
    82   check(bfs_test.dist(t)==3,"Bfs found a wrong path. " << bfs_test.dist(t));
     90//   check(bfs_test.dist(t)==3,"Bfs found a wrong path. " << bfs_test.dist(t));
    8391
    8492
    85   for(EdgeIt e(G); e==INVALID; ++e) {
    86     Node u=G.tail(e);
    87     Node v=G.head(e);
    88     check( !bfs_test.reached(u) ||
    89            (bfs_test.dist(v) > bfs_test.dist(u)+1),
    90            "Wrong output.");
    91   }
     93//   for(EdgeIt e(G); e==INVALID; ++e) {
     94//     Node u=G.tail(e);
     95//     Node v=G.head(e);
     96//     check( !bfs_test.reached(u) ||
     97//         (bfs_test.dist(v) > bfs_test.dist(u)+1),
     98//         "Wrong output.");
     99//   }
    92100
    93   for(NodeIt v(G); v==INVALID; ++v) {
    94     check(bfs_test.reached(v),"Each node should be reached.");
    95     if ( bfs_test.pred(v)!=INVALID ) {
    96       Edge e=bfs_test.pred(v);
    97       Node u=G.tail(e);
    98       check(u==bfs_test.predNode(v),"Wrong tree.");
    99       check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
    100             "Wrong distance. Difference: "
    101             << std::abs(bfs_test.dist(v) - bfs_test.dist(u)
    102                         - 1));
    103     }
    104   }
     101//   for(NodeIt v(G); v==INVALID; ++v) {
     102//     check(bfs_test.reached(v),"Each node should be reached.");
     103//     if ( bfs_test.pred(v)!=INVALID ) {
     104//       Edge e=bfs_test.pred(v);
     105//       Node u=G.tail(e);
     106//       check(u==bfs_test.predNode(v),"Wrong tree.");
     107//       check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
     108//          "Wrong distance. Difference: "
     109//          << std::abs(bfs_test.dist(v) - bfs_test.dist(u)
     110//                      - 1));
     111//     }
     112//   }
    105113}
    106114
Note: See TracChangeset for help on using the changeset viewer.