1.1 --- a/test/graph_utils_test.cc Fri Oct 14 11:02:34 2005 +0000
1.2 +++ b/test/graph_utils_test.cc Fri Oct 14 11:03:40 2005 +0000
1.3 @@ -77,6 +77,46 @@
1.4 checkSnapDeg<ListGraph>();
1.5 checkSnapDeg<SmartGraph>();
1.6
1.7 + {
1.8 + const int nodeNum = 10;
1.9 + const int edgeNum = 100;
1.10 + ListGraph graph;
1.11 + InDegMap<ListGraph> inDeg(graph);
1.12 + std::vector<ListGraph::Node> nodes(nodeNum);
1.13 + for (int i = 0; i < nodeNum; ++i) {
1.14 + nodes[i] = graph.addNode();
1.15 + }
1.16 + std::vector<ListGraph::Edge> edges(edgeNum);
1.17 + for (int i = 0; i < edgeNum; ++i) {
1.18 + edges[i] =
1.19 + graph.addEdge(nodes[urandom(nodeNum)], nodes[urandom(nodeNum)]);
1.20 + }
1.21 + for (int i = 0; i < nodeNum; ++i) {
1.22 + check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]),
1.23 + "Wrong in degree map");
1.24 + }
1.25 + for (int i = 0; i < edgeNum; ++i) {
1.26 + graph.changeTarget(edges[i], nodes[urandom(nodeNum)]);
1.27 + }
1.28 + for (int i = 0; i < nodeNum; ++i) {
1.29 + check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]),
1.30 + "Wrong in degree map");
1.31 + }
1.32 + for (int i = 0; i < edgeNum; ++i) {
1.33 + graph.changeSource(edges[i], nodes[urandom(nodeNum)]);
1.34 + }
1.35 + for (int i = 0; i < nodeNum; ++i) {
1.36 + check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]),
1.37 + "Wrong in degree map");
1.38 + }
1.39 + for (int i = 0; i < edgeNum; ++i) {
1.40 + graph.reverseEdge(edges[i]);
1.41 + }
1.42 + for (int i = 0; i < nodeNum; ++i) {
1.43 + check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]),
1.44 + "Wrong in degree map");
1.45 + }
1.46 + }
1.47
1.48 ///Everything is OK
1.49 std::cout << __FILE__ ": All tests passed.\n";