Use only a single (cached) variable to hold the version number.
1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
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 #include <lemon/list_graph.h>
20 #include <lemon/maps.h>
21 #include <lemon/unionfind.h>
22 #include "test_tools.h"
24 using namespace lemon;
27 typedef UnionFindEnum<ListGraph::NodeMap<int> > UFE;
31 ListGraph::NodeMap<int> base(g);
33 vector<ListGraph::Node> n;
35 for(int i=0;i<20;i++) n.push_back(g.addNode());
40 check(U.join(n[1],n[2]) != -1, "Something is wrong with UnionFindEnum");
49 check(U.join(n[1],n[4]) != -1, "Something is wrong with UnionFindEnum");
50 check(U.join(n[2],n[4]) == -1, "Something is wrong with UnionFindEnum");
51 check(U.join(n[3],n[5]) != -1, "Something is wrong with UnionFindEnum");
54 U.insert(n[8],U.find(n[5]));
57 check(U.size(U.find(n[4])) == 3, "Something is wrong with UnionFindEnum");
58 check(U.size(U.find(n[5])) == 3, "Something is wrong with UnionFindEnum");
59 check(U.size(U.find(n[6])) == 1, "Something is wrong with UnionFindEnum");
60 check(U.size(U.find(n[2])) == 3, "Something is wrong with UnionFindEnum");
64 U.insert(n[10],U.find(n[9]));
67 check(U.join(n[8],n[10]) != -1, "Something is wrong with UnionFindEnum");
70 check(U.size(U.find(n[4])) == 3, "Something is wrong with UnionFindEnum");
71 check(U.size(U.find(n[9])) == 5, "Something is wrong with UnionFindEnum");
73 check(U.size(U.find(n[8])) == 5, "Something is wrong with UnionFindEnum");
78 check(U.size(U.find(n[10])) == 4, "Something is wrong with UnionFindEnum");
79 check(U.size(U.find(n[2])) == 2, "Something is wrong with UnionFindEnum");
82 U.split(U.find(n[8]));
85 check(U.size(U.find(n[4])) == 2, "Something is wrong with UnionFindEnum");
86 check(U.size(U.find(n[3])) == 1, "Something is wrong with UnionFindEnum");
87 check(U.size(U.find(n[2])) == 2, "Something is wrong with UnionFindEnum");
90 check(U.join(n[3],n[4]) != -1, "Something is wrong with UnionFindEnum");
91 check(U.join(n[2],n[4]) == -1, "Something is wrong with UnionFindEnum");
94 check(U.size(U.find(n[4])) == 3, "Something is wrong with UnionFindEnum");
95 check(U.size(U.find(n[3])) == 3, "Something is wrong with UnionFindEnum");
96 check(U.size(U.find(n[2])) == 3, "Something is wrong with UnionFindEnum");
98 U.eraseClass(U.find(n[4]));
99 U.eraseClass(U.find(n[7]));