COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/test/graph_factory_test.cc @ 1221:6706c788ebb5

Last change on this file since 1221:6706c788ebb5 was 1164:80bb73097736, checked in by Alpar Juttner, 20 years ago

A year has passed again.

File size: 3.9 KB
Line 
1/* -*- C++ -*-
2 * src/test/graph_test.cc - Part of LEMON, a generic C++ optimization library
3 *
4 * Copyright (C) 2005 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
17#include<iostream>
18#include<lemon/smart_graph.h>
19#include<lemon/concept/graph.h>
20#include<lemon/concept/maps.h>
21#include<lemon/list_graph_base.h>
22#include<lemon/full_graph.h>
23
24#include"test_tools.h"
25#include"graph_test.h"
26
27/**
28\file
29This test makes consistency checks of list graph structures.
30
31G.addNode(), G.addEdge(), G.source(), G.target()
32
33\todo Checks for empty graphs and isolated points.
34conversion.
35*/
36
37using namespace lemon;
38
39template<class Graph> void bidirPetersen(Graph &G)
40{
41  typedef typename Graph::Edge Edge;
42  typedef typename Graph::EdgeIt EdgeIt;
43 
44  checkGraphEdgeList(G,15);
45 
46  std::vector<Edge> ee;
47 
48  for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(e);
49
50  for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
51    G.addEdge(G.target(*p),G.source(*p));
52}
53
54template<class Graph> void checkPetersen(Graph &G)
55{
56  typedef typename Graph::Node Node;
57
58  typedef typename Graph::EdgeIt EdgeIt;
59  typedef typename Graph::NodeIt NodeIt;
60
61  checkGraphNodeList(G,10);
62  checkGraphEdgeList(G,30);
63
64  for(NodeIt n(G);n!=INVALID;++n) {
65    checkGraphInEdgeList(G,n,3);
66    checkGraphOutEdgeList(G,n,3);
67  } 
68}
69
70//Compile Graph
71template void lemon::concept::checkCompileStaticGraph<concept::StaticGraph>
72(concept::StaticGraph &);
73
74template
75void lemon::concept::checkCompileExtendableGraph<concept::ExtendableGraph>
76(concept::ExtendableGraph &);
77
78template
79void lemon::concept::checkCompileErasableGraph<concept::ErasableGraph>
80(concept::ErasableGraph &);
81
82//Compile SmartGraph
83template
84void lemon::concept::checkCompileExtendableGraph<SmartGraph>(SmartGraph &);
85template
86void lemon::concept::checkCompileGraphFindEdge<SmartGraph>(SmartGraph &);
87
88//Compile SymSmartGraph
89//template void hugo::checkCompileGraph<SymSmartGraph>(SymSmartGraph &);
90//template void hugo::checkCompileGraphFindEdge<SymSmartGraph>(SymSmartGraph &);
91
92//Compile ListGraph
93template
94void lemon::concept::checkCompileExtendableGraph<ListGraph>(ListGraph &);
95template
96void lemon::concept::checkCompileErasableGraph<ListGraph>(ListGraph &);
97template
98void lemon::concept::checkCompileGraphFindEdge<ListGraph>(ListGraph &);
99
100
101//Compile SymListGraph
102//template void hugo::checkCompileGraph<SymListGraph>(SymListGraph &);
103//template void hugo::checkCompileErasableGraph<SymListGraph>(SymListGraph &);
104//template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
105
106//Compile FullGraph
107template void lemon::concept::checkCompileStaticGraph<FullGraph>(FullGraph &);
108template
109void lemon::concept::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
110
111
112int main()
113{
114  {
115    SmartGraph G;
116    addPetersen(G);
117    bidirPetersen(G);
118    checkPetersen(G);
119  }
120  {
121    ListGraph G;
122    addPetersen(G);
123    bidirPetersen(G);
124    checkPetersen(G);
125  }
126  {
127    //    SymSmartGraph G;
128    //    addPetersen(G);
129    //    checkPetersen(G);
130  }
131  {
132    //    SymListGraph G;
133    //    addPetersen(G);
134    //    checkPetersen(G);
135  }
136
137  ///\file
138  ///\todo map tests.
139  ///\todo copy constr tests.
140
141
142  // Some map tests.
143  // FIXME: These shouldn't be here.
144  using namespace concept;
145  function_requires< ReadMapConcept< ReadMap<int,int> > >();
146  function_requires< WriteMapConcept< WriteMap<int,int> > >();
147  function_requires< ReadWriteMapConcept< ReadWriteMap<int,int> > >();
148  function_requires< ReferenceMapConcept< ReferenceMap<int,int> > >();
149
150
151  std::cout << __FILE__ ": All tests passed.\n";
152
153  return 0;
154}
Note: See TracBrowser for help on using the repository browser.