test/graph_maps_test.h
changeset 215 17c644f5f98d
parent 171 02f4d5d9bfd7
equal deleted inserted replaced
0:32673bf12f05 1:f20bfa16983d
     1 /* -*- C++ -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2008
     5  * Copyright (C) 2003-2008
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
    69     }
    69     }
    70 
    70 
    71     std::vector<Arc> arcs;
    71     std::vector<Arc> arcs;
    72     for (int i = 0; i < num; ++i) {
    72     for (int i = 0; i < num; ++i) {
    73       for (int j = 0; j < i; ++j) {
    73       for (int j = 0; j < i; ++j) {
    74 	arcs.push_back(graph.addArc(nodes[i], nodes[j]));
    74         arcs.push_back(graph.addArc(nodes[i], nodes[j]));
    75       }
    75       }
    76     }
    76     }
    77 
    77 
    78     typedef typename Graph::template ArcMap<int> IntArcMap;
    78     typedef typename Graph::template ArcMap<int> IntArcMap;
    79     IntArcMap map(graph, 42);
    79     IntArcMap map(graph, 42);
    82       check(map[arcs[i]] == 42, "Wrong map constructor.");
    82       check(map[arcs[i]] == 42, "Wrong map constructor.");
    83     }
    83     }
    84 
    84 
    85     for (int i = 0; i < num; ++i) {
    85     for (int i = 0; i < num; ++i) {
    86       for (int j = i + 1; j < num; ++j) {
    86       for (int j = i + 1; j < num; ++j) {
    87 	arcs.push_back(graph.addArc(nodes[i], nodes[j]));
    87         arcs.push_back(graph.addArc(nodes[i], nodes[j]));
    88 	map[arcs.back()] = 23;
    88         map[arcs.back()] = 23;
    89         check(map[arcs.back()] == 23, "Wrong operator[].");
    89         check(map[arcs.back()] == 23, "Wrong operator[].");
    90       }
    90       }
    91     }
    91     }
    92     map = constMap<Arc>(12);
    92     map = constMap<Arc>(12);
    93     for (int i = 0; i < int(arcs.size()); ++i) {
    93     for (int i = 0; i < int(arcs.size()); ++i) {
   111     }
   111     }
   112 
   112 
   113     std::vector<Edge> edges;
   113     std::vector<Edge> edges;
   114     for (int i = 0; i < num; ++i) {
   114     for (int i = 0; i < num; ++i) {
   115       for (int j = 0; j < i; ++j) {
   115       for (int j = 0; j < i; ++j) {
   116 	edges.push_back(graph.addEdge(nodes[i], nodes[j]));
   116         edges.push_back(graph.addEdge(nodes[i], nodes[j]));
   117       }
   117       }
   118     }
   118     }
   119 
   119 
   120     typedef typename Graph::template EdgeMap<int> IntEdgeMap;
   120     typedef typename Graph::template EdgeMap<int> IntEdgeMap;
   121     IntEdgeMap map(graph, 42);
   121     IntEdgeMap map(graph, 42);
   124       check(map[edges[i]] == 42, "Wrong map constructor.");
   124       check(map[edges[i]] == 42, "Wrong map constructor.");
   125     }
   125     }
   126 
   126 
   127     for (int i = 0; i < num; ++i) {
   127     for (int i = 0; i < num; ++i) {
   128       for (int j = i + 1; j < num; ++j) {
   128       for (int j = i + 1; j < num; ++j) {
   129 	edges.push_back(graph.addEdge(nodes[i], nodes[j]));
   129         edges.push_back(graph.addEdge(nodes[i], nodes[j]));
   130 	map[edges.back()] = 23;
   130         map[edges.back()] = 23;
   131         check(map[edges.back()] == 23, "Wrong operator[].");
   131         check(map[edges.back()] == 23, "Wrong operator[].");
   132       }
   132       }
   133     }
   133     }
   134     map = constMap<Edge>(12);
   134     map = constMap<Edge>(12);
   135     for (int i = 0; i < int(edges.size()); ++i) {
   135     for (int i = 0; i < int(edges.size()); ++i) {