2 * test/graph_test.h - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
16 #ifndef LEMON_TEST_GRAPH_TEST_H
17 #define LEMON_TEST_GRAPH_TEST_H
19 #include <lemon/graph_utils.h>
20 #include "test_tools.h"
24 //! \brief Some utility and test cases to test graph classes.
27 template<class Graph> void checkGraphNodeList(Graph &G, int nn)
29 typename Graph::NodeIt n(G);
30 for(int i=0;i<nn;i++) {
31 check(n!=INVALID,"Wrong Node list linking.");
34 check(n==INVALID,"Wrong Node list linking.");
38 void checkGraphEdgeList(Graph &G, int nn)
40 typedef typename Graph::EdgeIt EdgeIt;
43 for(int i=0;i<nn;i++) {
44 check(e!=INVALID,"Wrong Edge list linking.");
47 check(e==INVALID,"Wrong Edge list linking.");
51 void checkGraphOutEdgeList(Graph &G, typename Graph::Node n, int nn)
53 typename Graph::OutEdgeIt e(G,n);
54 for(int i=0;i<nn;i++) {
55 check(e!=INVALID,"Wrong OutEdge list linking.");
56 check(n==G.source(e), "Wrong OutEdge list linking.");
59 check(e==INVALID,"Wrong OutEdge list linking.");
62 template<class Graph> void
63 checkGraphInEdgeList(Graph &G, typename Graph::Node n, int nn)
65 typename Graph::InEdgeIt e(G,n);
66 for(int i=0;i<nn;i++) {
67 check(e!=INVALID,"Wrong InEdge list linking.");
68 check(n==G.target(e), "Wrong InEdge list linking.");
71 check(e==INVALID,"Wrong InEdge list linking.");
74 template <class Graph>
80 checkBidirPetersen(G, num);
83 template <class Graph>
84 void checkGraphIterators(const Graph& graph) {
85 typedef typename Graph::Node Node;
86 typedef typename Graph::NodeIt NodeIt;
87 typedef typename Graph::Edge Edge;
88 typedef typename Graph::EdgeIt EdgeIt;
89 typedef typename Graph::InEdgeIt InEdgeIt;
90 typedef typename Graph::OutEdgeIt OutEdgeIt;
91 typedef ConEdgeIt<Graph> ConEdgeIt;
93 for (NodeIt it(graph); it != INVALID; ++it) {}
97 ///\todo Check target(), source() as well;