test_tools.h

Go to the documentation of this file.
00001 /* -*- C++ -*- 00002 * src/test/test_tools.h - Part of LEMON, a generic C++ optimization library 00003 * 00004 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 00005 * (Egervary Combinatorial Optimization Research Group, EGRES). 00006 * 00007 * Permission to use, modify and distribute this software is granted 00008 * provided that this copyright notice appears in all copies. For 00009 * precise terms see the accompanying LICENSE file. 00010 * 00011 * This software is provided "AS IS" with no warranty of any kind, 00012 * express or implied, and with no claim as to its suitability for any 00013 * purpose. 00014 * 00015 */ 00016 00017 #ifndef LEMON_TEST_TEST_TOOLS_H 00018 #define LEMON_TEST_TEST_TOOLS_H 00019 00023 00024 00025 #include<iostream> 00026 #include<vector> 00027 00029 00041 #define check(rc, msg) \ 00042 if(!(rc)) { \ 00043 std::cerr << __FILE__ ":" << __LINE__ << ": error: " << msg << std::endl; \ 00044 exit(1); \ 00045 } else { } \ 00046 00047 00048 00051 template<class Graph> struct PetStruct 00052 { 00054 std::vector<typename Graph::Node> outer; 00056 std::vector<typename Graph::Node> inner; 00058 std::vector<typename Graph::Edge> incir; 00060 std::vector<typename Graph::Edge> outcir; 00062 std::vector<typename Graph::Edge> chords; 00063 }; 00064 00065 00066 00068 00071 00072 template<typename Graph> 00073 PetStruct<Graph> addPetersen(Graph &G,int num=5) 00074 { 00075 PetStruct<Graph> n; 00076 00077 for(int i=0;i<num;i++) { 00078 n.outer.push_back(G.addNode()); 00079 n.inner.push_back(G.addNode()); 00080 } 00081 00082 for(int i=0;i<num;i++) { 00083 n.chords.push_back(G.addEdge(n.outer[i],n.inner[i])); 00084 n.outcir.push_back(G.addEdge(n.outer[i],n.outer[(i+1)%5])); 00085 n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2)%5])); 00086 } 00087 return n; 00088 } 00089 00090 00091 00092 #endif

Generated on Thu Sep 30 12:18:34 2004 for LEMON by doxygen 1.3.8