diff -r 0c7d717b9538 -r eb8bb91ba9e2 test/graph_utils_test.cc --- a/test/graph_utils_test.cc Fri Oct 14 11:02:34 2005 +0000 +++ b/test/graph_utils_test.cc Fri Oct 14 11:03:40 2005 +0000 @@ -77,6 +77,46 @@ checkSnapDeg(); checkSnapDeg(); + { + const int nodeNum = 10; + const int edgeNum = 100; + ListGraph graph; + InDegMap inDeg(graph); + std::vector nodes(nodeNum); + for (int i = 0; i < nodeNum; ++i) { + nodes[i] = graph.addNode(); + } + std::vector edges(edgeNum); + for (int i = 0; i < edgeNum; ++i) { + edges[i] = + graph.addEdge(nodes[urandom(nodeNum)], nodes[urandom(nodeNum)]); + } + for (int i = 0; i < nodeNum; ++i) { + check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), + "Wrong in degree map"); + } + for (int i = 0; i < edgeNum; ++i) { + graph.changeTarget(edges[i], nodes[urandom(nodeNum)]); + } + for (int i = 0; i < nodeNum; ++i) { + check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), + "Wrong in degree map"); + } + for (int i = 0; i < edgeNum; ++i) { + graph.changeSource(edges[i], nodes[urandom(nodeNum)]); + } + for (int i = 0; i < nodeNum; ++i) { + check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), + "Wrong in degree map"); + } + for (int i = 0; i < edgeNum; ++i) { + graph.reverseEdge(edges[i]); + } + for (int i = 0; i < nodeNum; ++i) { + check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), + "Wrong in degree map"); + } + } ///Everything is OK std::cout << __FILE__ ": All tests passed.\n";