/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- * vim: set ts=8 sts=2 et sw=2 tw=80:
*/ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
void run() {
finder = new TestComponentFinder(cx); for (unsigned i = 0; i < vertex_count; ++i) {
finder->addNode(&Vertex[i]);
}
resultsList = finder->getResultsList();
}
bool group(int vertex, ...) {
TestNode* v = resultsList;
delete finder;
finder = nullptr; returntrue;
}
END_TEST(testFindSCCs)
BEGIN_TEST(testFindSCCsStackLimit) { /* * Test what happens if recusion causes the stack to become full while * traversing the graph. * * The test case is a large number of vertices, almost all of which are * arranged in a linear chain. The last few are left unlinked to exercise * adding vertices after the stack full condition has already been detected. * * Such an arrangement with no cycles would normally result in one group for * each vertex, but since the stack is exhasted in processing a single group * is returned containing all the vertices.
*/ constunsigned max = 1000000; constunsigned initial = 10;
TestNode* vertices = new TestNode[max](); for (unsigned i = initial; i < (max - 10); ++i) {
CHECK(vertices[i].gcGraphEdges.put(&vertices[i + 1]));
}
TestComponentFinder finder(cx); for (unsigned i = 0; i < max; ++i) {
finder.addNode(&vertices[i]);
}
TestNode* r = finder.getResultsList();
CHECK(r);
TestNode* v = r;
unsigned count = 0; while (v) {
++count;
v = v->nextNodeInGroup();
}
CHECK(count == max - initial);
count = 0;
v = r->nextGroup(); while (v) {
++count;
CHECK(!v->nextNodeInGroup());
v = v->nextGroup();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.