Port graph_to_eps() and Color from svn -r3482.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #include "test_tools.h"
20 // #include <lemon/smart_graph.h>
21 #include <lemon/list_graph.h>
22 #include <lemon/dfs.h>
23 #include <lemon/path.h>
24 #include <lemon/concepts/digraph.h>
26 using namespace lemon;
28 const int PET_SIZE =5;
31 void check_Dfs_SmartDigraph_Compile()
33 typedef concepts::Digraph Digraph;
35 typedef Digraph::Arc Arc;
36 typedef Digraph::Node Node;
37 typedef Digraph::ArcIt ArcIt;
38 typedef Digraph::NodeIt NodeIt;
40 typedef Dfs<Digraph> DType;
49 // DType::PredNodeMap pn(G);
56 e = dfs_test.predArc(n);
57 n = dfs_test.predNode(n);
58 d = dfs_test.distMap();
59 p = dfs_test.predMap();
60 // pn = dfs_test.predNodeMap();
61 b = dfs_test.reached(n);
63 Path<Digraph> pp = dfs_test.path(n);
67 void check_Dfs_Function_Compile()
70 typedef concepts::Digraph Digraph;
72 typedef Digraph::Arc Arc;
73 typedef Digraph::Node Node;
74 typedef Digraph::ArcIt ArcIt;
75 typedef Digraph::NodeIt NodeIt;
76 typedef concepts::ReadMap<Arc,VType> LengthMap;
80 dfs(g).source(Node()).run();
82 .predMap(concepts::WriteMap<Node,Arc>())
83 .distMap(concepts::WriteMap<Node,VType>())
84 .reachedMap(concepts::ReadWriteMap<Node,bool>())
85 .processedMap(concepts::WriteMap<Node,bool>())
93 // typedef SmartDigraph Digraph;
94 typedef ListDigraph Digraph;
96 typedef Digraph::Arc Arc;
97 typedef Digraph::Node Node;
98 typedef Digraph::ArcIt ArcIt;
99 typedef Digraph::NodeIt NodeIt;
100 typedef Digraph::ArcMap<int> LengthMap;
104 PetStruct<Digraph> ps = addPetersen(G,PET_SIZE);
109 Dfs<Digraph> dfs_test(G);
112 Path<Digraph> p = dfs_test.path(t);
113 check(p.length()==dfs_test.dist(t),"path() found a wrong path.");
114 check(checkPath(G, p),"path() found a wrong path.");
115 check(pathSource(G, p) == s,"path() found a wrong path.");
116 check(pathTarget(G, p) == t,"path() found a wrong path.");
118 for(NodeIt v(G); v!=INVALID; ++v) {
119 check(dfs_test.reached(v),"Each node should be reached.");
120 if ( dfs_test.predArc(v)!=INVALID ) {
121 Arc e=dfs_test.predArc(v);
123 check(u==dfs_test.predNode(v),"Wrong tree.");
124 check(dfs_test.dist(v) - dfs_test.dist(u) == 1,
125 "Wrong distance. (" << dfs_test.dist(u) << "->"
126 <<dfs_test.dist(v) << ')');