diff -r 3ea28f39218b -r f694f75de683 test/graph_utils_test.h --- a/test/graph_utils_test.h Mon Jul 18 15:09:37 2005 +0000 +++ b/test/graph_utils_test.h Mon Jul 18 15:10:22 2005 +0000 @@ -18,6 +18,8 @@ #include "test_tools.h" +#include +#include //! \ingroup misc //! \file @@ -37,6 +39,41 @@ check(countInEdges(graph, it) == 3, "Wrong in degree number."); } } + + template + void checkFindEdge() { + typedef typename Graph::Node Node; + typedef typename Graph::Edge Edge; + typedef typename Graph::NodeIt NodeIt; + typedef typename Graph::EdgeIt EdgeIt; + Graph graph; + srand(time(0)); + for (int i = 0; i < 10; ++i) { + graph.addNode(); + } + DescriptorMap nodes(graph); + typename DescriptorMap::InverseMap invNodes(nodes); + for (int i = 0; i < 100; ++i) { + int src = (int)(rand() / (RAND_MAX + 1.0) * invNodes.size()); + int trg = (int)(rand() / (RAND_MAX + 1.0) * invNodes.size()); + graph.addEdge(invNodes[src], invNodes[trg]); + } + typename Graph::template EdgeMap found(graph, false); + DescriptorMap edges(graph); + for (NodeIt src(graph); src != INVALID; ++src) { + for (NodeIt trg(graph); trg != INVALID; ++trg) { + for (ConEdgeIt con(graph, src, trg); con != INVALID; ++con) { + check(graph.source(con) == src, "Wrong source."); + check(graph.target(con) == trg, "Wrong target."); + check(found[con] == false, "The edge found already."); + found[con] = true; + } + } + } + for (EdgeIt it(graph); it != INVALID; ++it) { + check(found[it] == true, "The edge is not found."); + } + } } //namespace lemon