klao@962
|
1 |
// -*- C++ -*-
|
klao@962
|
2 |
|
klao@962
|
3 |
#include <lemon/undir_graph_extender.h>
|
klao@962
|
4 |
#include <lemon/concept/undir_graph.h>
|
klao@962
|
5 |
#include <lemon/list_graph.h>
|
klao@962
|
6 |
#include <lemon/smart_graph.h>
|
klao@962
|
7 |
#include <lemon/full_graph.h>
|
klao@962
|
8 |
|
klao@1053
|
9 |
#include <lemon/graph_utils.h>
|
klao@1053
|
10 |
|
klao@962
|
11 |
#include "test_tools.h"
|
klao@962
|
12 |
|
klao@962
|
13 |
|
klao@962
|
14 |
using namespace lemon;
|
klao@962
|
15 |
using namespace lemon::concept;
|
klao@962
|
16 |
|
klao@1053
|
17 |
void check_concepts() {
|
klao@962
|
18 |
typedef UndirGraphExtender<ListGraphBase> UndirListGraphBase;
|
klao@962
|
19 |
|
klao@962
|
20 |
typedef IterableUndirGraphExtender<
|
klao@962
|
21 |
AlterableUndirGraphExtender<UndirListGraphBase> > IterableUndirListGraph;
|
klao@962
|
22 |
|
klao@1022
|
23 |
typedef MappableUndirGraphExtender<IterableUndirListGraph>
|
klao@1022
|
24 |
MappableUndirListGraph;
|
klao@1022
|
25 |
|
klao@1022
|
26 |
typedef ErasableUndirGraphExtender<
|
klao@1022
|
27 |
ClearableUndirGraphExtender<
|
klao@1022
|
28 |
ExtendableUndirGraphExtender<MappableUndirListGraph> > > Graph;
|
klao@1022
|
29 |
|
klao@1022
|
30 |
checkConcept<BaseIterableUndirGraphConcept, Graph>();
|
klao@1022
|
31 |
checkConcept<IterableUndirGraphConcept, Graph>();
|
klao@1022
|
32 |
checkConcept<MappableUndirGraphConcept, Graph>();
|
klao@1022
|
33 |
|
klao@1022
|
34 |
checkConcept<UndirGraph, Graph>();
|
klao@1022
|
35 |
checkConcept<ErasableUndirGraph, Graph>();
|
klao@962
|
36 |
|
klao@1034
|
37 |
checkConcept<UndirGraph, UndirListGraph>();
|
klao@1034
|
38 |
checkConcept<ErasableUndirGraph, UndirListGraph>();
|
klao@1034
|
39 |
|
klao@1034
|
40 |
checkConcept<UndirGraph, UndirSmartGraph>();
|
klao@1034
|
41 |
checkConcept<ExtendableUndirGraph, UndirSmartGraph>();
|
klao@1034
|
42 |
|
klao@1030
|
43 |
checkConcept<UndirGraph, UndirGraph>();
|
klao@1053
|
44 |
}
|
klao@1053
|
45 |
|
klao@1053
|
46 |
typedef UndirListGraph Graph;
|
klao@1053
|
47 |
typedef Graph::Node Node;
|
klao@1053
|
48 |
typedef Graph::UndirEdge UEdge;
|
klao@1053
|
49 |
typedef Graph::Edge Edge;
|
klao@1053
|
50 |
typedef Graph::NodeIt NodeIt;
|
klao@1053
|
51 |
typedef Graph::UndirEdgeIt UEdgeIt;
|
klao@1053
|
52 |
typedef Graph::EdgeIt EdgeIt;
|
klao@1053
|
53 |
|
klao@1053
|
54 |
void check_item_counts(Graph &g, int n, int e) {
|
klao@1053
|
55 |
check(countNodes(g)==n, "Wrong node number.");
|
klao@1053
|
56 |
check(countEdges(g)==2*e, "Wrong edge number.");
|
klao@1053
|
57 |
}
|
klao@1053
|
58 |
|
klao@1053
|
59 |
void print_items(Graph &g) {
|
klao@1053
|
60 |
cout << "Nodes" << endl;
|
klao@1053
|
61 |
int i=0;
|
klao@1053
|
62 |
for(NodeIt it(g); it!=INVALID; ++it, ++i) {
|
klao@1053
|
63 |
cout << " " << i << ": " << g.id(it) << endl;
|
klao@1053
|
64 |
}
|
klao@1053
|
65 |
|
klao@1053
|
66 |
cout << "UndirEdge" << endl;
|
klao@1053
|
67 |
i=0;
|
klao@1053
|
68 |
for(UEdgeIt it(g); it!=INVALID; ++it, ++i) {
|
klao@1053
|
69 |
cout << " " << i << ": " << g.id(it)
|
klao@1053
|
70 |
<< " (" << g.id(g.source(it)) << ", " << g.id(g.target(it))
|
klao@1053
|
71 |
<< ")" << endl;
|
klao@1053
|
72 |
}
|
klao@1053
|
73 |
|
klao@1053
|
74 |
cout << "Edge" << endl;
|
klao@1053
|
75 |
i=0;
|
klao@1053
|
76 |
for(EdgeIt it(g); it!=INVALID; ++it, ++i) {
|
klao@1053
|
77 |
cout << " " << i << ": " << g.id(it)
|
klao@1053
|
78 |
<< " (" << g.id(g.source(it)) << ", " << g.id(g.target(it))
|
klao@1053
|
79 |
<< ")" << endl;
|
klao@1053
|
80 |
}
|
klao@1053
|
81 |
|
klao@1053
|
82 |
}
|
klao@1053
|
83 |
|
klao@1053
|
84 |
int main() {
|
klao@1053
|
85 |
check_concepts();
|
klao@1053
|
86 |
|
klao@1053
|
87 |
|
klao@1053
|
88 |
Graph g;
|
klao@1053
|
89 |
|
klao@1053
|
90 |
check_item_counts(g,0,0);
|
klao@1053
|
91 |
|
klao@1053
|
92 |
Node
|
klao@1053
|
93 |
n1 = g.addNode(),
|
klao@1053
|
94 |
n2 = g.addNode(),
|
klao@1053
|
95 |
n3 = g.addNode();
|
klao@1053
|
96 |
|
klao@1053
|
97 |
UEdge
|
klao@1053
|
98 |
e1 = g.addEdge(n1, n2),
|
klao@1053
|
99 |
e2 = g.addEdge(n2, n3);
|
klao@1053
|
100 |
|
klao@1053
|
101 |
// print_items(g);
|
klao@1053
|
102 |
|
klao@1053
|
103 |
check_item_counts(g,3,2);
|
klao@1030
|
104 |
|
klao@962
|
105 |
return 0;
|
klao@962
|
106 |
}
|