Edge and nodemap edition is done.
3 #include <lemon/bits/undir_graph_extender.h>
4 #include <lemon/concept/undir_graph.h>
5 #include <lemon/list_graph.h>
6 #include <lemon/smart_graph.h>
7 #include <lemon/full_graph.h>
9 #include <lemon/graph_utils.h>
11 #include "test_tools.h"
14 using namespace lemon;
15 using namespace lemon::concept;
17 void check_concepts() {
18 typedef UndirGraphExtender<ListGraphBase> UndirListGraphBase;
20 typedef IterableUndirGraphExtender<
21 AlterableUndirGraphExtender<UndirListGraphBase> > IterableUndirListGraph;
23 typedef MappableUndirGraphExtender<IterableUndirListGraph>
24 MappableUndirListGraph;
26 typedef ErasableUndirGraphExtender<
27 ClearableUndirGraphExtender<
28 ExtendableUndirGraphExtender<MappableUndirListGraph> > > Graph;
30 checkConcept<BaseIterableUndirGraphConcept, Graph>();
31 checkConcept<IterableUndirGraphConcept, Graph>();
32 checkConcept<MappableUndirGraphConcept, Graph>();
34 checkConcept<UndirGraph, Graph>();
35 checkConcept<ErasableUndirGraph, Graph>();
37 checkConcept<UndirGraph, UndirListGraph>();
38 checkConcept<ErasableUndirGraph, UndirListGraph>();
40 checkConcept<UndirGraph, UndirSmartGraph>();
41 checkConcept<ExtendableUndirGraph, UndirSmartGraph>();
43 checkConcept<UndirGraph, UndirFullGraph>();
45 checkConcept<UndirGraph, UndirGraph>();
48 template <typename Graph>
49 void check_item_counts(Graph &g, int n, int e) {
50 check(countNodes(g)==n, "Wrong node number.");
51 check(countEdges(g)==2*e, "Wrong edge number.");
54 template <typename Graph>
55 void print_items(Graph &g) {
57 typedef typename Graph::NodeIt NodeIt;
58 typedef typename Graph::UndirEdgeIt UEdgeIt;
59 typedef typename Graph::EdgeIt EdgeIt;
61 std::cout << "Nodes" << std::endl;
63 for(NodeIt it(g); it!=INVALID; ++it, ++i) {
64 std::cout << " " << i << ": " << g.id(it) << std::endl;
67 std::cout << "UndirEdge" << std::endl;
69 for(UEdgeIt it(g); it!=INVALID; ++it, ++i) {
70 std::cout << " " << i << ": " << g.id(it)
71 << " (" << g.id(g.source(it)) << ", " << g.id(g.target(it))
75 std::cout << "Edge" << std::endl;
77 for(EdgeIt it(g); it!=INVALID; ++it, ++i) {
78 std::cout << " " << i << ": " << g.id(it)
79 << " (" << g.id(g.source(it)) << ", " << g.id(g.target(it))
85 template <typename Graph>
88 typedef typename Graph::Node Node;
89 typedef typename Graph::UndirEdge UEdge;
90 typedef typename Graph::Edge Edge;
91 typedef typename Graph::NodeIt NodeIt;
92 typedef typename Graph::UndirEdgeIt UEdgeIt;
93 typedef typename Graph::EdgeIt EdgeIt;
97 check_item_counts(g,0,0);
105 e1 = g.addEdge(n1, n2),
106 e2 = g.addEdge(n2, n3);
110 check_item_counts(g,3,2);
118 check_graph<UndirListGraph>();
119 check_graph<UndirSmartGraph>();
123 check_item_counts(g, 5, 10);