We have UndirGraph, so BidirGraph has been removed.
2 * src/test/bfs_test.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
17 #include <test/test_tools.h>
18 #include <lemon/smart_graph.h>
20 #include <lemon/concept/graph.h>
22 using namespace lemon;
24 const int PET_SIZE =5;
27 void check_Bfs_Compile()
29 typedef concept::StaticGraph Graph;
31 typedef Graph::Edge Edge;
32 typedef Graph::Node Node;
33 typedef Graph::EdgeIt EdgeIt;
34 typedef Graph::NodeIt NodeIt;
36 typedef marci::Bfs<Graph> BType;
45 BType::PredNodeMap pn(G);
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);
57 n = bfs_test.predNode(n);
58 d = bfs_test.distMap();
59 p = bfs_test.predMap();
60 pn = bfs_test.predNodeMap();
61 b = bfs_test.reached(n);
68 typedef SmartGraph Graph;
70 typedef Graph::Edge Edge;
71 typedef Graph::Node Node;
72 typedef Graph::EdgeIt EdgeIt;
73 typedef Graph::NodeIt NodeIt;
74 typedef Graph::EdgeMap<int> LengthMap;
78 PetStruct<Graph> ps = addPetersen(G,PET_SIZE);
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);
90 // check(bfs_test.dist(t)==3,"Bfs found a wrong path. " << bfs_test.dist(t));
93 // for(EdgeIt e(G); e==INVALID; ++e) {
94 // Node u=G.source(e);
95 // Node v=G.target(e);
96 // check( !bfs_test.reached(u) ||
97 // (bfs_test.dist(v) > bfs_test.dist(u)+1),
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.source(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)