Changeset 1021:a12cca3ad15a in lemon-main for test
- Timestamp:
- 11/15/10 09:46:08 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/bpgraph_test.cc
r1020 r1021 18 18 19 19 #include <lemon/concepts/bpgraph.h> 20 //#include <lemon/list_graph.h>20 #include <lemon/list_graph.h> 21 21 #include <lemon/smart_graph.h> 22 22 #include <lemon/full_graph.h> … … 108 108 } 109 109 110 template <class Graph> 110 template <class BpGraph> 111 void checkBpGraphErase() { 112 TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph); 113 114 BpGraph G; 115 Node 116 n1 = G.addRedNode(), n2 = G.addBlueNode(), 117 n3 = G.addBlueNode(), n4 = G.addRedNode(); 118 Edge 119 e1 = G.addEdge(n1, n2), e2 = G.addEdge(n1, n3), 120 e3 = G.addEdge(n4, n2), e4 = G.addEdge(n4, n3); 121 122 // Check edge deletion 123 G.erase(e2); 124 125 checkGraphNodeList(G, 4); 126 checkGraphRedNodeList(G, 2); 127 checkGraphBlueNodeList(G, 2); 128 checkGraphEdgeList(G, 3); 129 checkGraphArcList(G, 6); 130 131 checkGraphIncEdgeArcLists(G, n1, 1); 132 checkGraphIncEdgeArcLists(G, n2, 2); 133 checkGraphIncEdgeArcLists(G, n3, 1); 134 checkGraphIncEdgeArcLists(G, n4, 2); 135 136 checkGraphConEdgeList(G, 3); 137 checkGraphConArcList(G, 6); 138 139 // Check node deletion 140 G.erase(n3); 141 142 checkGraphNodeList(G, 3); 143 checkGraphRedNodeList(G, 2); 144 checkGraphBlueNodeList(G, 1); 145 checkGraphEdgeList(G, 2); 146 checkGraphArcList(G, 4); 147 148 checkGraphIncEdgeArcLists(G, n1, 1); 149 checkGraphIncEdgeArcLists(G, n2, 2); 150 checkGraphIncEdgeArcLists(G, n4, 1); 151 152 checkGraphConEdgeList(G, 2); 153 checkGraphConArcList(G, 4); 154 155 } 156 157 template <class BpGraph> 158 void checkBpGraphAlter() { 159 TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph); 160 161 BpGraph G; 162 Node 163 n1 = G.addRedNode(), n2 = G.addBlueNode(), 164 n3 = G.addBlueNode(), n4 = G.addRedNode(); 165 Edge 166 e1 = G.addEdge(n1, n2), e2 = G.addEdge(n1, n3), 167 e3 = G.addEdge(n4, n2), e4 = G.addEdge(n4, n3); 168 169 G.changeRed(e2, n4); 170 check(G.redNode(e2) == n4, "Wrong red node"); 171 check(G.blueNode(e2) == n3, "Wrong blue node"); 172 173 checkGraphNodeList(G, 4); 174 checkGraphRedNodeList(G, 2); 175 checkGraphBlueNodeList(G, 2); 176 checkGraphEdgeList(G, 4); 177 checkGraphArcList(G, 8); 178 179 checkGraphIncEdgeArcLists(G, n1, 1); 180 checkGraphIncEdgeArcLists(G, n2, 2); 181 checkGraphIncEdgeArcLists(G, n3, 2); 182 checkGraphIncEdgeArcLists(G, n4, 3); 183 184 checkGraphConEdgeList(G, 4); 185 checkGraphConArcList(G, 8); 186 187 G.changeBlue(e2, n2); 188 check(G.redNode(e2) == n4, "Wrong red node"); 189 check(G.blueNode(e2) == n2, "Wrong blue node"); 190 191 checkGraphNodeList(G, 4); 192 checkGraphRedNodeList(G, 2); 193 checkGraphBlueNodeList(G, 2); 194 checkGraphEdgeList(G, 4); 195 checkGraphArcList(G, 8); 196 197 checkGraphIncEdgeArcLists(G, n1, 1); 198 checkGraphIncEdgeArcLists(G, n2, 3); 199 checkGraphIncEdgeArcLists(G, n3, 1); 200 checkGraphIncEdgeArcLists(G, n4, 3); 201 202 checkGraphConEdgeList(G, 4); 203 checkGraphConArcList(G, 8); 204 } 205 206 207 template <class BpGraph> 111 208 void checkBpGraphSnapshot() { 112 TEMPLATE_BPGRAPH_TYPEDEFS( Graph);113 114 Graph G;209 TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph); 210 211 BpGraph G; 115 212 Node 116 213 n1 = G.addRedNode(), … … 127 224 checkGraphArcList(G, 4); 128 225 129 typename Graph::Snapshot snapshot(G);226 typename BpGraph::Snapshot snapshot(G); 130 227 131 228 Node n4 = G.addRedNode(); … … 191 288 } 192 289 193 template <typename Graph>290 template <typename BpGraph> 194 291 void checkBpGraphValidity() { 195 TEMPLATE_ GRAPH_TYPEDEFS(Graph);196 Graph g;292 TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph); 293 BpGraph g; 197 294 198 295 Node … … 326 423 327 424 void checkGraphs() { 425 { // Checking ListGraph 426 checkBpGraphBuild<ListBpGraph>(); 427 checkBpGraphErase<ListBpGraph>(); 428 checkBpGraphAlter<ListBpGraph>(); 429 checkBpGraphSnapshot<ListBpGraph>(); 430 checkBpGraphValidity<ListBpGraph>(); 431 } 328 432 { // Checking SmartGraph 329 433 checkBpGraphBuild<SmartBpGraph>();
Note: See TracChangeset
for help on using the changeset viewer.