For cygwin compatibility.
2 * src/test/dfs_test.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2005 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_tools.h"
18 #include <lemon/smart_graph.h>
19 #include <lemon/dfs.h>
20 #include <lemon/concept/graph.h>
22 using namespace lemon;
24 const int PET_SIZE =5;
27 void check_Dfs_SmartGraph_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 Dfs<Graph> DType;
45 // DType::PredNodeMap pn(G);
53 n = dfs_test.predNode(n);
54 d = dfs_test.distMap();
55 p = dfs_test.predMap();
56 // pn = dfs_test.predNodeMap();
57 b = dfs_test.reached(n);
62 void check_Dfs_Function_Compile()
65 typedef concept::StaticGraph Graph;
67 typedef Graph::Edge Edge;
68 typedef Graph::Node Node;
69 typedef Graph::EdgeIt EdgeIt;
70 typedef Graph::NodeIt NodeIt;
71 typedef concept::ReadMap<Edge,VType> LengthMap;
73 dfs(Graph(),Node()).run();
74 dfs(Graph()).source(Node()).run();
76 .predMap(concept::WriteMap<Node,Edge>())
77 .distMap(concept::WriteMap<Node,VType>())
78 .reachedMap(concept::ReadWriteMap<Node,bool>())
79 .processedMap(concept::WriteMap<Node,bool>())
87 typedef SmartGraph Graph;
89 typedef Graph::Edge Edge;
90 typedef Graph::Node Node;
91 typedef Graph::EdgeIt EdgeIt;
92 typedef Graph::NodeIt NodeIt;
93 typedef Graph::EdgeMap<int> LengthMap;
97 PetStruct<Graph> ps = addPetersen(G,PET_SIZE);
102 Dfs<Graph> dfs_test(G);
105 for(NodeIt v(G); v!=INVALID; ++v) {
106 check(dfs_test.reached(v),"Each node should be reached.");
107 if ( dfs_test.pred(v)!=INVALID ) {
108 Edge e=dfs_test.pred(v);
110 check(u==dfs_test.predNode(v),"Wrong tree.");
111 check(dfs_test.dist(v) - dfs_test.dist(u) == 1,
112 "Wrong distance. (" << dfs_test.dist(u) << "->"
113 <<dfs_test.dist(v) << ')');