An additional simplier interface for static size graphs.
Node operator()(int) for getting node by index
int index(Node node) for getting index by node
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
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 #ifndef LEMON_TEST_MAP_TEST_H
20 #define LEMON_TEST_MAP_TEST_H
25 #include "test_tools.h"
30 //! \brief Some utilities to test map classes.
35 template <typename Graph>
36 void checkGraphNodeMap() {
40 typedef typename Graph::Node Node;
42 std::vector<Node> nodes;
43 for (int i = 0; i < num; ++i) {
44 nodes.push_back(graph.addNode());
46 typedef typename Graph::template NodeMap<int> IntNodeMap;
47 IntNodeMap map(graph, 42);
48 for (int i = 0; i < (int)nodes.size(); ++i) {
49 check(map[nodes[i]] == 42, "Wrong map constructor.");
51 for (int i = 0; i < num; ++i) {
52 nodes.push_back(graph.addNode());
53 map[nodes.back()] = 23;
55 map = constMap<Node>(12);
56 for (int i = 0; i < (int)nodes.size(); ++i) {
57 check(map[nodes[i]] == 12, "Wrong map constructor.");
63 template <typename Graph>
64 void checkGraphEdgeMap() {
68 typedef typename Graph::Node Node;
69 typedef typename Graph::Edge Edge;
71 std::vector<Node> nodes;
72 for (int i = 0; i < num; ++i) {
73 nodes.push_back(graph.addNode());
76 std::vector<Edge> edges;
77 for (int i = 0; i < num; ++i) {
78 for (int j = 0; j < i; ++j) {
79 edges.push_back(graph.addEdge(nodes[i], nodes[j]));
83 typedef typename Graph::template EdgeMap<int> IntEdgeMap;
84 IntEdgeMap map(graph, 42);
86 for (int i = 0; i < (int)edges.size(); ++i) {
87 check(map[edges[i]] == 42, "Wrong map constructor.");
90 for (int i = 0; i < num; ++i) {
91 for (int j = i + 1; j < num; ++j) {
92 edges.push_back(graph.addEdge(nodes[i], nodes[j]));
93 map[edges.back()] = 23;
96 map = constMap<Edge>(12);
97 for (int i = 0; i < (int)edges.size(); ++i) {
98 check(map[edges[i]] == 12, "Wrong map constructor.");