COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/test/graph_test.cc @ 878:86b42ec55f3e

Last change on this file since 878:86b42ec55f3e was 873:f3a30fda2e49, checked in by Alpar Juttner, 20 years ago
File size: 3.4 KB
RevLine 
[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]12This test makes consistency checks of list graph structures.
13
[774]14G.addNode(), G.addEdge(), G.tail(), G.head()
[503]15
[592]16\todo Checks for empty graphs and isolated points.
[774]17conversion.
[503]18*/
19
20using namespace hugo;
21
22template<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
37template<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
[873]55template void hugo::checkCompileStaticGraph<skeleton::StaticGraphSkeleton>
[793]56(skeleton::StaticGraphSkeleton &);
57
[873]58template void hugo::checkCompileGraph<skeleton::ExtendableGraphSkeleton>
59(skeleton::ExtendableGraphSkeleton &);
[793]60
[873]61template void hugo::checkCompileErasableGraph<skeleton::ErasableGraphSkeleton>
[826]62(skeleton::ErasableGraphSkeleton &);
[733]63
[774]64//Compile SmartGraph
[873]65template void hugo::checkCompileGraph<SmartGraph>(SmartGraph &);
66template void hugo::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
[783]67
[774]68//Compile SymSmartGraph
[873]69template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
70template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
[774]71
72//Compile ListGraph
[873]73template void hugo::checkCompileGraph<ListGraph>(ListGraph &);
74template void hugo::checkCompileErasableGraph<ListGraph>(ListGraph &);
75template void hugo::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
[774]76
[783]77
[774]78//Compile SymListGraph
[873]79template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
80template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
81template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
[774]82
83//Compile FullGraph
[873]84template void hugo::checkCompileStaticGraph<FullGraph>(FullGraph &);
85template void hugo::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
[550]86
[774]87//Compile EdgeSet <ListGraph>
[873]88template void hugo::checkCompileGraph<EdgeSet <ListGraph> >
[800]89(EdgeSet <ListGraph> &);
[873]90template void hugo::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
91(EdgeSet <ListGraph> &);
92template void hugo::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
[800]93(EdgeSet <ListGraph> &);
[774]94
95//Compile EdgeSet <NodeSet>
[873]96template void hugo::checkCompileGraph<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
97template void hugo::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
[800]98(EdgeSet <NodeSet> &);
[873]99template void hugo::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
[800]100(EdgeSet <NodeSet> &);
[774]101
[503]102
103int main()
104{
105  {
106    SmartGraph G;
107    addPetersen(G);
108    bidirPetersen(G);
109    checkPetersen(G);
110  }
[578]111  {
112    ListGraph G;
113    addPetersen(G);
114    bidirPetersen(G);
115    checkPetersen(G);
116  }
[503]117  {
118    SymSmartGraph G;
119    addPetersen(G);
120    checkPetersen(G);
121  }
[578]122  {
123    SymListGraph G;
124    addPetersen(G);
125    checkPetersen(G);
126  }
[503]127
[774]128  ///\file
129  ///\todo map tests.
130  ///\todo copy constr tests.
[503]131
132  std::cout << __FILE__ ": All tests passed.\n";
133
[579]134  return 0;
[503]135}
Note: See TracBrowser for help on using the repository browser.