diff -r cd72eae05bdf -r 3c00344f49c9 test/graph_test.h --- a/test/graph_test.h Mon Jul 16 16:21:40 2018 +0200 +++ b/test/graph_test.h Wed Oct 17 19:14:07 2018 +0200 @@ -2,7 +2,7 @@ * * This file is a part of LEMON, a generic C++ optimization library. * - * Copyright (C) 2003-2009 + * Copyright (C) 2003-2013 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * @@ -41,6 +41,42 @@ } template + void checkGraphRedNodeList(const Graph &G, int cnt) + { + typename Graph::RedNodeIt n(G); + for(int i=0;i + void checkGraphBlueNodeList(const Graph &G, int cnt) + { + typename Graph::BlueNodeIt n(G); + for(int i=0;i void checkGraphArcList(const Graph &G, int cnt) { typename Graph::ArcIt e(G); @@ -166,6 +202,7 @@ template void checkNodeIds(const Graph& G) { + typedef typename Graph::Node Node; std::set values; for (typename Graph::NodeIt n(G); n != INVALID; ++n) { check(G.nodeFromId(G.id(n)) == n, "Wrong id"); @@ -173,10 +210,38 @@ check(G.id(n) <= G.maxNodeId(), "Wrong maximum id"); values.insert(G.id(n)); } + check(G.maxId(Node()) <= G.maxNodeId(), "Wrong maximum id"); + } + + template + void checkRedNodeIds(const Graph& G) { + typedef typename Graph::RedNode RedNode; + std::set values; + for (typename Graph::RedNodeIt n(G); n != INVALID; ++n) { + check(G.red(n), "Wrong partition"); + check(values.find(G.id(n)) == values.end(), "Wrong id"); + check(G.id(n) <= G.maxRedId(), "Wrong maximum id"); + values.insert(G.id(n)); + } + check(G.maxId(RedNode()) == G.maxRedId(), "Wrong maximum id"); + } + + template + void checkBlueNodeIds(const Graph& G) { + typedef typename Graph::BlueNode BlueNode; + std::set values; + for (typename Graph::BlueNodeIt n(G); n != INVALID; ++n) { + check(G.blue(n), "Wrong partition"); + check(values.find(G.id(n)) == values.end(), "Wrong id"); + check(G.id(n) <= G.maxBlueId(), "Wrong maximum id"); + values.insert(G.id(n)); + } + check(G.maxId(BlueNode()) == G.maxBlueId(), "Wrong maximum id"); } template void checkArcIds(const Graph& G) { + typedef typename Graph::Arc Arc; std::set values; for (typename Graph::ArcIt a(G); a != INVALID; ++a) { check(G.arcFromId(G.id(a)) == a, "Wrong id"); @@ -184,10 +249,12 @@ check(G.id(a) <= G.maxArcId(), "Wrong maximum id"); values.insert(G.id(a)); } + check(G.maxId(Arc()) <= G.maxArcId(), "Wrong maximum id"); } template void checkEdgeIds(const Graph& G) { + typedef typename Graph::Edge Edge; std::set values; for (typename Graph::EdgeIt e(G); e != INVALID; ++e) { check(G.edgeFromId(G.id(e)) == e, "Wrong id"); @@ -195,6 +262,7 @@ check(G.id(e) <= G.maxEdgeId(), "Wrong maximum id"); values.insert(G.id(e)); } + check(G.maxId(Edge()) <= G.maxEdgeId(), "Wrong maximum id"); } template @@ -228,6 +296,66 @@ } template + void checkGraphRedNodeMap(const Graph& G) { + typedef typename Graph::Node Node; + typedef typename Graph::RedNodeIt RedNodeIt; + + typedef typename Graph::template RedNodeMap IntRedNodeMap; + IntRedNodeMap map(G, 42); + for (RedNodeIt it(G); it != INVALID; ++it) { + check(map[it] == 42, "Wrong map constructor."); + } + int s = 0; + for (RedNodeIt it(G); it != INVALID; ++it) { + map[it] = 0; + check(map[it] == 0, "Wrong operator[]."); + map.set(it, s); + check(map[it] == s, "Wrong set."); + ++s; + } + s = s * (s - 1) / 2; + for (RedNodeIt it(G); it != INVALID; ++it) { + s -= map[it]; + } + check(s == 0, "Wrong sum."); + + // map = constMap(12); + // for (NodeIt it(G); it != INVALID; ++it) { + // check(map[it] == 12, "Wrong operator[]."); + // } + } + + template + void checkGraphBlueNodeMap(const Graph& G) { + typedef typename Graph::Node Node; + typedef typename Graph::BlueNodeIt BlueNodeIt; + + typedef typename Graph::template BlueNodeMap IntBlueNodeMap; + IntBlueNodeMap map(G, 42); + for (BlueNodeIt it(G); it != INVALID; ++it) { + check(map[it] == 42, "Wrong map constructor."); + } + int s = 0; + for (BlueNodeIt it(G); it != INVALID; ++it) { + map[it] = 0; + check(map[it] == 0, "Wrong operator[]."); + map.set(it, s); + check(map[it] == s, "Wrong set."); + ++s; + } + s = s * (s - 1) / 2; + for (BlueNodeIt it(G); it != INVALID; ++it) { + s -= map[it]; + } + check(s == 0, "Wrong sum."); + + // map = constMap(12); + // for (NodeIt it(G); it != INVALID; ++it) { + // check(map[it] == 12, "Wrong operator[]."); + // } + } + + template void checkGraphArcMap(const Graph& G) { typedef typename Graph::Arc Arc; typedef typename Graph::ArcIt ArcIt;