📄 bigraphvertexdiagnose.h
字号:
// now rebuild the same binary tree so we can remove arcs a different // way // // attach this as the first node in the BiGraph // bigraph1.getStart()->insertArcParent(vertices[0], 0.0, false); // now loop over the remaining vertices - the tree will be built when we // get to 63. the 63rd vertex will only have one child (the root node // takes one vertex) // for (long i = 0; i < 63; i++) { vertices[i]->insertArcParent(vertices[2 * i + 1], (float)i, false); vertices[i]->insertArcParent(vertices[2 * i + 2], (float)i, false); } vertices[63]->insertArcParent(vertices[127], (float)127, false); // reverse engineer the binary tree to make sure it is correct // bigraph1.getStart()->gotoFirstParent(); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } // -------------------------------------------------------------------- // // 4. class-specific public methods: // item manipulation methods // // -------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing class-specific public methods: item manupulation methods...\n"); Console::increaseIndention(); } { // get the first element and make sure it is the proper root vertex // if (!(bigraph1.getStart()->isAdjacentChild(vertices[0])) || (bigraph1.getStart()->getCurrChild()->getVertex() != vertices[0]) || (bigraph1.getStart()->getCurrChild()-> getVertex()->getItem()->ne(*chars[0]))) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // the leaf vertices should be empty // for (long i = 127; i >= 64; --i) { if (!vertices[i]->isEmptyChild()) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } } // handle the 63rd item that has only one child vertex // if (vertices[63]->getCurrChild()->getVertex() != vertices[2 * 63 + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the first arc // if (!vertices[63]->removeArcChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the remaining vertices should have the appropriate child vertices in the // appropriate order and with the appropriate weight // for (long i = 62; i >= 32; --i) { // go to the front of the list // vertices[i]->gotoFirstChild(); // the first vertex should point to the (2*i + 1) element // if (vertices[i]->getCurrChild()->getVertex() != vertices[2 * i + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // move to the next arc // vertices[i]->gotoNextChild(); // the second vertex should point to the (2*i + 2) element // if (vertices[i]->getCurrChild()->getVertex() != vertices[2 * i + 2]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove all arcs from this vertex // if (!vertices[i]->removeAllArcsChild()) { return Error::handle(name(), L"removeAllArcs", Error::TEST, __FILE__, __LINE__); } if (!vertices[i]->isEmptyChild()) { return Error::handle(name(), L"removeAllArcs", Error::TEST, __FILE__, __LINE__); } } // the remaining vertices should have the appropriate child vertices in the // appropriate order and with the appropriate weight // for (long i = 31; i >= 0; --i) { // go to the front of the list // vertices[i]->gotoFirstChild(); // the first vertex should point to the (2*i + 1) element // if (vertices[i]->getCurrChild()->getVertex() != vertices[2 * i + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // move to the next vertex // vertices[i]->gotoNextChild(); // the second vertex should point to the (2*i + 2) element // if (vertices[i]->getCurrChild()->getVertex() != vertices[2 * i + 2]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the arcs in turn // if (!vertices[i]->removeArcChild(vertices[2 * i + 2])) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } if (!vertices[i]->removeArcChild(vertices[2 * i + 1])) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // make sure the list is now empty // if (!vertices[i]->isEmptyChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } } // the root vertex should still be attached to the start vertex of the // BiGraph // if (bigraph1.getStart()->getCurrChild()->getVertex() != vertices[0]) { return Error::handle(name(), L"insertArc/removeArc", Error::TEST, __FILE__, __LINE__); } // disconnect the root vertex // if (!bigraph1.getStart()->removeArcChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the BiGraph start vertex should now be empty // if (!bigraph1.getStart()->isEmptyChild()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } } { // get the first element and make sure it is the proper root vertex // if (!(bigraph1.getStart()->isAdjacentParent(vertices[0])) || (bigraph1.getStart()->getCurrParent()->getVertex() != vertices[0]) || (bigraph1.getStart()->getCurrParent()-> getVertex()->getItem()->ne(*chars[0]))) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // the leaf vertices should be empty // for (long i = 127; i >= 64; --i) { if (!vertices[i]->isEmptyParent()) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } } // handle the 63rd item that has only one child vertex // if (vertices[63]->getCurrParent()->getVertex() != vertices[2 * 63 + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the first arc // if (!vertices[63]->removeArcParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the remaining vertices should have the appropriate child vertices in the // appropriate order and with the appropriate weight // for (long i = 62; i >= 32; --i) { // go to the front of the list // vertices[i]->gotoFirstParent(); // the first vertex should point to the (2*i + 1) element // if (vertices[i]->getCurrParent()->getVertex() != vertices[2 * i + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // move to the next arc // vertices[i]->gotoNextParent(); // the second vertex should point to the (2*i + 2) element // if (vertices[i]->getCurrParent()->getVertex() != vertices[2 * i + 2]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove all arcs from this vertex // if (!vertices[i]->removeAllArcsParent()) { return Error::handle(name(), L"removeAllArcs", Error::TEST, __FILE__, __LINE__); } if (!vertices[i]->isEmptyParent()) { return Error::handle(name(), L"removeAllArcs", Error::TEST, __FILE__, __LINE__); } } // the remaining vertices should have the appropriate child vertices in the // appropriate order and with the appropriate weight // for (long i = 31; i >= 0; --i) { // go to the front of the list // vertices[i]->gotoFirstParent(); // the first vertex should point to the (2*i + 1) element // if (vertices[i]->getCurrParent()->getVertex() != vertices[2 * i + 1]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // move to the next vertex // vertices[i]->gotoNextParent(); // the second vertex should point to the (2*i + 2) element // if (vertices[i]->getCurrParent()->getVertex() != vertices[2 * i + 2]) { return Error::handle(name(), L"insertArc", Error::TEST, __FILE__, __LINE__); } // remove the arcs in turn // if (!vertices[i]->removeArcParent(vertices[2 * i + 2])) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } if (!vertices[i]->removeArcParent(vertices[2 * i + 1])) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // make sure the list is now empty // if (!vertices[i]->isEmptyParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } } // the root vertex should still be attached to the start vertex of the // BiGraph // if (bigraph1.getStart()->getCurrParent()->getVertex() != vertices[0]) { return Error::handle(name(), L"insertArc/removeArc", Error::TEST, __FILE__, __LINE__); } // disconnect the root vertex // if (!bigraph1.getStart()->removeArcParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } // the BiGraph start vertex should now be empty // if (!bigraph1.getStart()->isEmptyParent()) { return Error::handle(name(), L"removeArc", Error::TEST, __FILE__, __LINE__); } } // clean up the memory // for (long i = 0; i < 128; i++) { delete chars[i]; delete vertices[i]; } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //--------------------------------------------------------------------- // // 7. print completion message // //--------------------------------------------------------------------- // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } if (level_a > Integral::NONE) { SysString output(L"diagnostics passed for class "); output.concat(name()); output.concat(L"\n"); Console::put(output); } // exit gracefully // return true;}// end of include file//#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -