Port graph_to_eps() and Color from svn -r3482.
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
21 #include <lemon/list_graph.h>
22 #include <lemon/maps.h>
23 #include <lemon/unionfind.h>
24 #include "test_tools.h"
26 using namespace lemon;
29 typedef UnionFindEnum<ListGraph::NodeMap<int> > UFE;
33 ListGraph::NodeMap<int> base(g);
35 vector<ListGraph::Node> n;
37 for(int i=0;i<20;i++) n.push_back(g.addNode());
42 check(U.join(n[1],n[2]) != -1,"Test failed.");
51 check(U.join(n[1],n[4]) != -1,"Test failed.");
52 check(U.join(n[2],n[4]) == -1,"Test failed.");
53 check(U.join(n[3],n[5]) != -1,"Test failed.");
56 U.insert(n[8],U.find(n[5]));
59 check(U.size(U.find(n[4])) == 3,"Test failed.");
60 check(U.size(U.find(n[5])) == 3,"Test failed.");
61 check(U.size(U.find(n[6])) == 1,"Test failed.");
62 check(U.size(U.find(n[2])) == 3,"Test failed.");
66 U.insert(n[10],U.find(n[9]));
69 check(U.join(n[8],n[10]) != -1,"Test failed.");
72 check(U.size(U.find(n[4])) == 3,"Test failed.");
73 check(U.size(U.find(n[9])) == 5,"Test failed.");
75 check(U.size(U.find(n[8])) == 5,"Test failed.");
80 check(U.size(U.find(n[10])) == 4,"Test failed.");
81 check(U.size(U.find(n[2])) == 2,"Test failed.");
84 U.split(U.find(n[8]));
87 check(U.size(U.find(n[4])) == 2,"Test failed.");
88 check(U.size(U.find(n[3])) == 1,"Test failed.");
89 check(U.size(U.find(n[2])) == 2,"Test failed.");
92 check(U.join(n[3],n[4]) != -1,"Test failed.");
93 check(U.join(n[2],n[4]) == -1,"Test failed.");
96 check(U.size(U.find(n[4])) == 3,"Test failed.");
97 check(U.size(U.find(n[3])) == 3,"Test failed.");
98 check(U.size(U.find(n[2])) == 3,"Test failed.");
100 U.eraseClass(U.find(n[4]));
101 U.eraseClass(U.find(n[7]));