[906] | 1 | /* -*- C++ -*- |
---|
[921] | 2 | * src/test/graph_test.cc - Part of LEMON, a generic C++ optimization library |
---|
[906] | 3 | * |
---|
| 4 | * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
| 5 | * (Egervary Combinatorial Optimization Research Group, EGRES). |
---|
| 6 | * |
---|
| 7 | * Permission to use, modify and distribute this software is granted |
---|
| 8 | * provided that this copyright notice appears in all copies. For |
---|
| 9 | * precise terms see the accompanying LICENSE file. |
---|
| 10 | * |
---|
| 11 | * This software is provided "AS IS" with no warranty of any kind, |
---|
| 12 | * express or implied, and with no claim as to its suitability for any |
---|
| 13 | * purpose. |
---|
| 14 | * |
---|
| 15 | */ |
---|
| 16 | |
---|
[503] | 17 | #include<iostream> |
---|
[921] | 18 | #include<lemon/smart_graph.h> |
---|
| 19 | #include<lemon/skeletons/graph.h> |
---|
| 20 | #include<lemon/list_graph.h> |
---|
| 21 | #include<lemon/full_graph.h> |
---|
[578] | 22 | |
---|
[567] | 23 | #include"test_tools.h" |
---|
[800] | 24 | #include"graph_test.h" |
---|
[567] | 25 | |
---|
[774] | 26 | /** |
---|
| 27 | \file |
---|
[503] | 28 | This test makes consistency checks of list graph structures. |
---|
| 29 | |
---|
[774] | 30 | G.addNode(), G.addEdge(), G.tail(), G.head() |
---|
[503] | 31 | |
---|
[592] | 32 | \todo Checks for empty graphs and isolated points. |
---|
[774] | 33 | conversion. |
---|
[503] | 34 | */ |
---|
| 35 | |
---|
[921] | 36 | using namespace lemon; |
---|
[503] | 37 | |
---|
| 38 | template<class Graph> void bidirPetersen(Graph &G) |
---|
| 39 | { |
---|
| 40 | typedef typename Graph::Edge Edge; |
---|
| 41 | typedef typename Graph::EdgeIt EdgeIt; |
---|
| 42 | |
---|
[800] | 43 | checkGraphEdgeList(G,15); |
---|
[503] | 44 | |
---|
| 45 | std::vector<Edge> ee; |
---|
| 46 | |
---|
[774] | 47 | for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e); |
---|
[503] | 48 | |
---|
| 49 | for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++) |
---|
| 50 | G.addEdge(G.head(*p),G.tail(*p)); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | template<class Graph> void checkPetersen(Graph &G) |
---|
| 54 | { |
---|
| 55 | typedef typename Graph::Node Node; |
---|
| 56 | |
---|
| 57 | typedef typename Graph::EdgeIt EdgeIt; |
---|
| 58 | typedef typename Graph::NodeIt NodeIt; |
---|
| 59 | |
---|
[800] | 60 | checkGraphNodeList(G,10); |
---|
| 61 | checkGraphEdgeList(G,30); |
---|
[503] | 62 | |
---|
[774] | 63 | for(NodeIt n(G);n!=INVALID;++n) { |
---|
[800] | 64 | checkGraphInEdgeList(G,n,3); |
---|
| 65 | checkGraphOutEdgeList(G,n,3); |
---|
[919] | 66 | ++n; |
---|
[503] | 67 | } |
---|
| 68 | } |
---|
| 69 | |
---|
[880] | 70 | //Compile Graph |
---|
[921] | 71 | template void lemon::checkCompileStaticGraph<skeleton::StaticGraph> |
---|
[880] | 72 | (skeleton::StaticGraph &); |
---|
[793] | 73 | |
---|
[921] | 74 | template void lemon::checkCompileGraph<skeleton::ExtendableGraph> |
---|
[880] | 75 | (skeleton::ExtendableGraph &); |
---|
[793] | 76 | |
---|
[921] | 77 | template void lemon::checkCompileErasableGraph<skeleton::ErasableGraph> |
---|
[880] | 78 | (skeleton::ErasableGraph &); |
---|
[733] | 79 | |
---|
[774] | 80 | //Compile SmartGraph |
---|
[921] | 81 | template void lemon::checkCompileGraph<SmartGraph>(SmartGraph &); |
---|
| 82 | template void lemon::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &); |
---|
[783] | 83 | |
---|
[774] | 84 | //Compile SymSmartGraph |
---|
[921] | 85 | template void lemon::checkCompileGraph<SymSmartGraph>(SymSmartGraph &); |
---|
| 86 | template void lemon::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &); |
---|
[774] | 87 | |
---|
| 88 | //Compile ListGraph |
---|
[921] | 89 | template void lemon::checkCompileGraph<ListGraph>(ListGraph &); |
---|
| 90 | template void lemon::checkCompileErasableGraph<ListGraph>(ListGraph &); |
---|
| 91 | template void lemon::checkCompileGraphFindEdge<ListGraph>(ListGraph &); |
---|
[774] | 92 | |
---|
[783] | 93 | |
---|
[774] | 94 | //Compile SymListGraph |
---|
[921] | 95 | template void lemon::checkCompileGraph<SymListGraph>(SymListGraph &); |
---|
| 96 | template void lemon::checkCompileErasableGraph<SymListGraph>(SymListGraph &); |
---|
| 97 | template void lemon::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &); |
---|
[774] | 98 | |
---|
| 99 | //Compile FullGraph |
---|
[921] | 100 | template void lemon::checkCompileStaticGraph<FullGraph>(FullGraph &); |
---|
| 101 | template void lemon::checkCompileGraphFindEdge<FullGraph>(FullGraph &); |
---|
[550] | 102 | |
---|
[774] | 103 | //Compile EdgeSet <ListGraph> |
---|
[921] | 104 | template void lemon::checkCompileGraph<EdgeSet <ListGraph> > |
---|
[800] | 105 | (EdgeSet <ListGraph> &); |
---|
[921] | 106 | template void lemon::checkCompileGraphEraseEdge<EdgeSet <ListGraph> > |
---|
[873] | 107 | (EdgeSet <ListGraph> &); |
---|
[921] | 108 | template void lemon::checkCompileGraphFindEdge<EdgeSet <ListGraph> > |
---|
[800] | 109 | (EdgeSet <ListGraph> &); |
---|
[774] | 110 | |
---|
| 111 | //Compile EdgeSet <NodeSet> |
---|
[921] | 112 | template void lemon::checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &); |
---|
| 113 | template void lemon::checkCompileGraphEraseEdge<EdgeSet <NodeSet> > |
---|
[800] | 114 | (EdgeSet <NodeSet> &); |
---|
[921] | 115 | template void lemon::checkCompileGraphFindEdge<EdgeSet <NodeSet> > |
---|
[800] | 116 | (EdgeSet <NodeSet> &); |
---|
[774] | 117 | |
---|
[503] | 118 | |
---|
| 119 | int main() |
---|
| 120 | { |
---|
| 121 | { |
---|
| 122 | SmartGraph G; |
---|
| 123 | addPetersen(G); |
---|
| 124 | bidirPetersen(G); |
---|
| 125 | checkPetersen(G); |
---|
| 126 | } |
---|
[578] | 127 | { |
---|
| 128 | ListGraph G; |
---|
| 129 | addPetersen(G); |
---|
| 130 | bidirPetersen(G); |
---|
| 131 | checkPetersen(G); |
---|
| 132 | } |
---|
[503] | 133 | { |
---|
[919] | 134 | SymSmartGraph G; |
---|
| 135 | addPetersen(G); |
---|
| 136 | checkPetersen(G); |
---|
[503] | 137 | } |
---|
[578] | 138 | { |
---|
[919] | 139 | SymListGraph G; |
---|
| 140 | addPetersen(G); |
---|
| 141 | checkPetersen(G); |
---|
[578] | 142 | } |
---|
[503] | 143 | |
---|
[774] | 144 | ///\file |
---|
| 145 | ///\todo map tests. |
---|
| 146 | ///\todo copy constr tests. |
---|
[503] | 147 | |
---|
| 148 | std::cout << __FILE__ ": All tests passed.\n"; |
---|
| 149 | |
---|
[579] | 150 | return 0; |
---|
[503] | 151 | } |
---|