[503] | 1 | #include<iostream> |
---|
[542] | 2 | #include<hugo/smart_graph.h> |
---|
[564] | 3 | #include<hugo/skeletons/graph.h> |
---|
[578] | 4 | #include<hugo/list_graph.h> |
---|
[592] | 5 | #include<hugo/full_graph.h> |
---|
[578] | 6 | |
---|
[567] | 7 | #include"test_tools.h" |
---|
[800] | 8 | #include"graph_test.h" |
---|
[567] | 9 | |
---|
[774] | 10 | /** |
---|
| 11 | \file |
---|
[503] | 12 | This test makes consistency checks of list graph structures. |
---|
| 13 | |
---|
[774] | 14 | G.addNode(), G.addEdge(), G.tail(), G.head() |
---|
[503] | 15 | |
---|
[592] | 16 | \todo Checks for empty graphs and isolated points. |
---|
[774] | 17 | conversion. |
---|
[503] | 18 | */ |
---|
| 19 | |
---|
| 20 | using namespace hugo; |
---|
| 21 | |
---|
| 22 | template<class Graph> void bidirPetersen(Graph &G) |
---|
| 23 | { |
---|
| 24 | typedef typename Graph::Edge Edge; |
---|
| 25 | typedef typename Graph::EdgeIt EdgeIt; |
---|
| 26 | |
---|
[800] | 27 | checkGraphEdgeList(G,15); |
---|
[503] | 28 | |
---|
| 29 | std::vector<Edge> ee; |
---|
| 30 | |
---|
[774] | 31 | for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e); |
---|
[503] | 32 | |
---|
| 33 | for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++) |
---|
| 34 | G.addEdge(G.head(*p),G.tail(*p)); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | template<class Graph> void checkPetersen(Graph &G) |
---|
| 38 | { |
---|
| 39 | typedef typename Graph::Node Node; |
---|
| 40 | |
---|
| 41 | typedef typename Graph::EdgeIt EdgeIt; |
---|
| 42 | typedef typename Graph::NodeIt NodeIt; |
---|
| 43 | |
---|
[800] | 44 | checkGraphNodeList(G,10); |
---|
| 45 | checkGraphEdgeList(G,30); |
---|
[503] | 46 | |
---|
[774] | 47 | for(NodeIt n(G);n!=INVALID;++n) { |
---|
[800] | 48 | checkGraphInEdgeList(G,n,3); |
---|
| 49 | checkGraphOutEdgeList(G,n,3); |
---|
[774] | 50 | ++n; |
---|
[503] | 51 | } |
---|
| 52 | } |
---|
| 53 | |
---|
[774] | 54 | //Compile GraphSkeleton |
---|
[793] | 55 | template void checkCompileStaticGraph<skeleton::StaticGraphSkeleton> |
---|
| 56 | (skeleton::StaticGraphSkeleton &); |
---|
| 57 | |
---|
[800] | 58 | template void checkCompileGraph<skeleton::GraphSkeleton> |
---|
| 59 | (skeleton::GraphSkeleton &); |
---|
[793] | 60 | |
---|
[826] | 61 | template void checkCompileErasableGraph<skeleton::ErasableGraphSkeleton> |
---|
| 62 | (skeleton::ErasableGraphSkeleton &); |
---|
[733] | 63 | |
---|
[774] | 64 | //Compile SmartGraph |
---|
[800] | 65 | template void checkCompileGraph<SmartGraph>(SmartGraph &); |
---|
| 66 | template void checkCompileGraphFindEdge<SmartGraph>(SmartGraph &); |
---|
[783] | 67 | |
---|
[774] | 68 | //Compile SymSmartGraph |
---|
[800] | 69 | template void checkCompileGraph<SymSmartGraph>(SymSmartGraph &); |
---|
| 70 | template void checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &); |
---|
[774] | 71 | |
---|
| 72 | //Compile ListGraph |
---|
[800] | 73 | template void checkCompileGraph<ListGraph>(ListGraph &); |
---|
| 74 | template void checkCompileErasableGraph<ListGraph>(ListGraph &); |
---|
| 75 | template void checkCompileGraphFindEdge<ListGraph>(ListGraph &); |
---|
[774] | 76 | |
---|
[783] | 77 | |
---|
[774] | 78 | //Compile SymListGraph |
---|
[800] | 79 | template void checkCompileGraph<SymListGraph>(SymListGraph &); |
---|
| 80 | template void checkCompileErasableGraph<SymListGraph>(SymListGraph &); |
---|
| 81 | template void checkCompileGraphFindEdge<SymListGraph>(SymListGraph &); |
---|
[774] | 82 | |
---|
| 83 | //Compile FullGraph |
---|
[592] | 84 | template void checkCompileStaticGraph<FullGraph>(FullGraph &); |
---|
[800] | 85 | template void checkCompileGraphFindEdge<FullGraph>(FullGraph &); |
---|
[550] | 86 | |
---|
[774] | 87 | //Compile EdgeSet <ListGraph> |
---|
[800] | 88 | template void checkCompileGraph<EdgeSet <ListGraph> >(EdgeSet <ListGraph> &); |
---|
| 89 | template void checkCompileGraphEraseEdge<EdgeSet <ListGraph> > |
---|
| 90 | (EdgeSet <ListGraph> &); |
---|
| 91 | template void checkCompileGraphFindEdge<EdgeSet <ListGraph> > |
---|
| 92 | (EdgeSet <ListGraph> &); |
---|
[774] | 93 | |
---|
| 94 | //Compile EdgeSet <NodeSet> |
---|
[800] | 95 | template void checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &); |
---|
| 96 | template void checkCompileGraphEraseEdge<EdgeSet <NodeSet> > |
---|
| 97 | (EdgeSet <NodeSet> &); |
---|
| 98 | template void checkCompileGraphFindEdge<EdgeSet <NodeSet> > |
---|
| 99 | (EdgeSet <NodeSet> &); |
---|
[774] | 100 | |
---|
[503] | 101 | |
---|
| 102 | int main() |
---|
| 103 | { |
---|
| 104 | { |
---|
| 105 | SmartGraph G; |
---|
| 106 | addPetersen(G); |
---|
| 107 | bidirPetersen(G); |
---|
| 108 | checkPetersen(G); |
---|
| 109 | } |
---|
[578] | 110 | { |
---|
| 111 | ListGraph G; |
---|
| 112 | addPetersen(G); |
---|
| 113 | bidirPetersen(G); |
---|
| 114 | checkPetersen(G); |
---|
| 115 | } |
---|
[503] | 116 | { |
---|
| 117 | SymSmartGraph G; |
---|
| 118 | addPetersen(G); |
---|
| 119 | checkPetersen(G); |
---|
| 120 | } |
---|
[578] | 121 | { |
---|
| 122 | SymListGraph G; |
---|
| 123 | addPetersen(G); |
---|
| 124 | checkPetersen(G); |
---|
| 125 | } |
---|
[503] | 126 | |
---|
[774] | 127 | ///\file |
---|
| 128 | ///\todo map tests. |
---|
| 129 | ///\todo copy constr tests. |
---|
[503] | 130 | |
---|
| 131 | std::cout << __FILE__ ": All tests passed.\n"; |
---|
| 132 | |
---|
[579] | 133 | return 0; |
---|
[503] | 134 | } |
---|