Fixed the mailinglist link and removed the gui section.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
22 #include <lemon/graph_utils.h>
24 #include <lemon/list_graph.h>
25 #include <lemon/smart_graph.h>
26 #include <lemon/full_graph.h>
28 #include "test_tools.h"
29 #include "graph_utils_test.h"
32 using namespace lemon;
38 typename Graph::Node n1=g.addNode();
39 typename Graph::Node n2=g.addNode();
41 InDegMap<Graph> ind(g);
45 typename Graph::Snapshot snap(g);
47 OutDegMap<Graph> outd(g);
49 check(ind[n1]==0 && ind[n2]==1, "Wrong InDegMap value.");
50 check(outd[n1]==1 && outd[n2]==0, "Wrong OutDegMap value.");
55 check(ind[n1]==1 && ind[n2]==2, "Wrong InDegMap value.");
56 check(outd[n1]==2 && outd[n2]==1, "Wrong OutDegMap value.");
60 check(ind[n1]==0 && ind[n2]==1, "Wrong InDegMap value.");
61 check(outd[n1]==1 && outd[n2]==0, "Wrong OutDegMap value.");
67 { // checking list graph
68 checkGraphCounters<ListGraph>();
69 checkFindEdge<ListGraph>();
71 { // checking smart graph
72 checkGraphCounters<SmartGraph>();
73 checkFindEdge<SmartGraph>();
78 check(countNodes(fg) == num, "FullGraph: wrong node number.");
79 check(countEdges(fg) == num*num, "FullGraph: wrong edge number.");
80 for (FullGraph::NodeIt src(fg); src != INVALID; ++src) {
81 for (FullGraph::NodeIt trg(fg); trg != INVALID; ++trg) {
82 ConEdgeIt<FullGraph> con(fg, src, trg);
83 check(con != INVALID, "There is no connecting edge.");
84 check(fg.source(con) == src, "Wrong source.");
85 check(fg.target(con) == trg, "Wrong target.");
86 check(++con == INVALID, "There is more connecting edge.");
91 //check In/OutDegMap (and Snapshot feature)
93 checkSnapDeg<ListGraph>();
94 checkSnapDeg<SmartGraph>();
97 const int nodeNum = 10;
98 const int edgeNum = 100;
100 InDegMap<ListGraph> inDeg(graph);
101 OutDegMap<ListGraph> outDeg(graph);
102 std::vector<ListGraph::Node> nodes(nodeNum);
103 for (int i = 0; i < nodeNum; ++i) {
104 nodes[i] = graph.addNode();
106 std::vector<ListGraph::Edge> edges(edgeNum);
107 for (int i = 0; i < edgeNum; ++i) {
109 graph.addEdge(nodes[urandom(nodeNum)], nodes[urandom(nodeNum)]);
111 for (int i = 0; i < nodeNum; ++i) {
112 check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]),
113 "Wrong in degree map");
115 for (int i = 0; i < nodeNum; ++i) {
116 check(outDeg[nodes[i]] == countOutEdges(graph, nodes[i]),
117 "Wrong in degree map");
122 std::cout << __FILE__ ": All tests passed.\n";