Newly created map is realized by the property givening by common sense.
2 * test/dfs_test.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, 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_tools.h"
18 #include <lemon/smart_graph.h>
19 #include <lemon/dfs.h>
20 #include <lemon/path.h>
21 #include <lemon/concept/graph.h>
23 using namespace lemon;
25 const int PET_SIZE =5;
28 void check_Dfs_SmartGraph_Compile()
30 typedef concept::StaticGraph Graph;
32 typedef Graph::Edge Edge;
33 typedef Graph::Node Node;
34 typedef Graph::EdgeIt EdgeIt;
35 typedef Graph::NodeIt NodeIt;
37 typedef Dfs<Graph> DType;
46 // DType::PredNodeMap pn(G);
54 n = dfs_test.predNode(n);
55 d = dfs_test.distMap();
56 p = dfs_test.predMap();
57 // pn = dfs_test.predNodeMap();
58 b = dfs_test.reached(n);
61 dfs_test.getPath(pp,n);
65 void check_Dfs_Function_Compile()
68 typedef concept::StaticGraph Graph;
70 typedef Graph::Edge Edge;
71 typedef Graph::Node Node;
72 typedef Graph::EdgeIt EdgeIt;
73 typedef Graph::NodeIt NodeIt;
74 typedef concept::ReadMap<Edge,VType> LengthMap;
76 dfs(Graph(),Node()).run();
77 dfs(Graph()).source(Node()).run();
79 .predMap(concept::WriteMap<Node,Edge>())
80 .distMap(concept::WriteMap<Node,VType>())
81 .reachedMap(concept::ReadWriteMap<Node,bool>())
82 .processedMap(concept::WriteMap<Node,bool>())
90 typedef SmartGraph Graph;
92 typedef Graph::Edge Edge;
93 typedef Graph::Node Node;
94 typedef Graph::EdgeIt EdgeIt;
95 typedef Graph::NodeIt NodeIt;
96 typedef Graph::EdgeMap<int> LengthMap;
100 PetStruct<Graph> ps = addPetersen(G,PET_SIZE);
105 Dfs<Graph> dfs_test(G);
109 check(dfs_test.getPath(p,t),"getPath() failed to set the path.");
110 check(p.length()==dfs_test.dist(t),"getPath() found a wrong path.");
112 for(NodeIt v(G); v!=INVALID; ++v) {
113 check(dfs_test.reached(v),"Each node should be reached.");
114 if ( dfs_test.pred(v)!=INVALID ) {
115 Edge e=dfs_test.pred(v);
117 check(u==dfs_test.predNode(v),"Wrong tree.");
118 check(dfs_test.dist(v) - dfs_test.dist(u) == 1,
119 "Wrong distance. (" << dfs_test.dist(u) << "->"
120 <<dfs_test.dist(v) << ')');