CMake improvements.
- documentation generation with Doxygen
- installation support
1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
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 <lemon/concepts/digraph.h>
20 #include <lemon/smart_graph.h>
21 #include <lemon/list_graph.h>
22 #include <lemon/bfs.h>
23 #include <lemon/path.h>
25 #include "graph_test.h"
26 #include "test_tools.h"
28 using namespace lemon;
30 void checkBfsCompile()
32 typedef concepts::Digraph Digraph;
33 typedef Bfs<Digraph> BType;
42 // BType::PredNodeMap pn(G);
49 e = bfs_test.predArc(n);
50 n = bfs_test.predNode(n);
51 d = bfs_test.distMap();
52 p = bfs_test.predMap();
53 // pn = bfs_test.predNodeMap();
54 b = bfs_test.reached(n);
56 Path<Digraph> pp = bfs_test.path(n);
59 void checkBfsFunctionCompile()
62 typedef concepts::Digraph Digraph;
63 typedef Digraph::Arc Arc;
64 typedef Digraph::Node Node;
68 bfs(g).source(Node()).run();
70 .predMap(concepts::WriteMap<Node,Arc>())
71 .distMap(concepts::WriteMap<Node,VType>())
72 .reachedMap(concepts::ReadWriteMap<Node,bool>())
73 .processedMap(concepts::WriteMap<Node,bool>())
77 template <class Digraph>
79 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
83 PetStruct<Digraph> ps = addPetersen(G, 5);
88 Bfs<Digraph> bfs_test(G);
91 check(bfs_test.dist(t)==3,"Bfs found a wrong path." << bfs_test.dist(t));
93 Path<Digraph> p = bfs_test.path(t);
94 check(p.length()==3,"path() found a wrong path.");
95 check(checkPath(G, p),"path() found a wrong path.");
96 check(pathSource(G, p) == s,"path() found a wrong path.");
97 check(pathTarget(G, p) == t,"path() found a wrong path.");
100 for(ArcIt e(G); e==INVALID; ++e) {
103 check( !bfs_test.reached(u) ||
104 (bfs_test.dist(v) > bfs_test.dist(u)+1),
108 for(NodeIt v(G); v==INVALID; ++v) {
109 check(bfs_test.reached(v),"Each node should be reached.");
110 if ( bfs_test.predArc(v)!=INVALID ) {
111 Arc e=bfs_test.predArc(v);
113 check(u==bfs_test.predNode(v),"Wrong tree.");
114 check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
115 "Wrong distance. Difference: "
116 << std::abs(bfs_test.dist(v) - bfs_test.dist(u)
124 checkBfs<ListDigraph>();
125 checkBfs<SmartDigraph>();