Loading isis/src/control/objs/ControlNet/ControlNet.cpp +1 −187 Original line number Diff line number Diff line Loading @@ -616,113 +616,6 @@ namespace Isis { } /** * Random breadth-first search. This meathod starts at a random serial, and * returns a list with the start serial as well as any serial which is * directly or indirectly connected to it. The list returned will contain * all the serials in the network if and only if the network is completely * connected. Otherwise, the list returned will be the entire island on * which a random image resides. * * @returns A List of connected graph nodes */ QList< ControlCubeGraphNode * > ControlNet::RandomBFS( QList< ControlCubeGraphNode * > nodes) const { qsrand(42); Shuffle(nodes); // for keeping track of visited nodes QMap< ControlCubeGraphNode *, bool > searchList; for (int i = 0; i < nodes.size(); i++) searchList.insert(nodes[i], false); // for storing nodes as they are found QSet< ControlCubeGraphNode * > results; QQueue< ControlCubeGraphNode * > q; q.enqueue(nodes[0]); while (q.size()) { ControlCubeGraphNode *curNode = q.dequeue(); if (!results.contains(curNode)) { // add to results results.insert(curNode); searchList[curNode] = true; // add all the neighbors to the queue QList< ControlCubeGraphNode * > neighbors = curNode->getAdjacentNodes(); Shuffle(neighbors); for (int i = 0; i < neighbors.size(); i++) q.enqueue(neighbors[i]); } } // end of breadth-first search return results.values(); } /** * Shuffles the QStrings in a QList< QString > * * @param list The list to be shuffled */ void ControlNet::Shuffle(QList< ControlCubeGraphNode * > & list) const { for (int i = list.size() - 1; i > 0; i--) { // standard form is qrand() / (RAND_MAX + 1.0) * (max + 1 - min) + min // min is always zero here so it is simplified to... int j = (int)(qrand() / (RAND_MAX + 1.0) * (i + 1)); qSwap(list[j], list[i]); } } /** * Calculate the band width and critical edges needed by the adjacency matrix * that could store cube connectivity if that matrix used the same ordering * as is in the provided list. Note that no adjacency matrices are ever used * in this class! * * Critical edges are edges that contribute to band width. * * @param serials A list of cube serial numbers. * * @returns A QPair such that the first element is the needed bandwidth for * the serials how they are currently ordered in the list, and the * second element is the number of critical edges. */ QPair< int, int > ControlNet::CalcBWAndCE(QList< QString > serials) const { for (int i = 0; i < serials.size(); i++) ASSERT(cubeGraphNodes->contains(serials[i])); int bw = 0; QList< int > colWidths; for (int i = 0; i < serials.size(); i++) { int colWidth = 0; ControlCubeGraphNode *node1 = (*cubeGraphNodes)[serials[i]]; for (int j = 0; j < serials.size(); j++) { if (i != j) { ControlCubeGraphNode *node2 = (*cubeGraphNodes)[serials[j]]; int colDiff = abs(i - j); if (node1->isConnected(node2) && colDiff > colWidth) colWidth = colDiff; } } colWidths.append(colWidth); if (colWidth > bw) bw = colWidth; } int criticalEdges = 0; foreach(int width, colWidths) { if (width == bw) criticalEdges++; } return qMakePair(bw, criticalEdges); } /** * Delete a ControlPoint from the network by the point's address. * Loading Loading @@ -817,7 +710,7 @@ namespace Isis { */ QList< QList< QString > > ControlNet::GetSerialConnections() const { QList< QList< QString > > islandStrings; QList< QList< ControlCubeGraphNode * > > islands = GetNodeConnections(); QList< QList< ControlCubeGraphNode * > > islands; for (int i = 0; i < islands.size(); i++) { QList< QString > newIsland; islandStrings.append(newIsland); Loading @@ -828,38 +721,6 @@ namespace Isis { } /** * This method searches through all the cube serial numbers in the network. * Serials which are connected to other serials through points are grouped * together in the same lists. The list containing the lists of strings is * nothing more than a list of islands such that each island is a list of * serials which are connected to each other. If the control network is * completely connected, then this list will only have one element (a list * of all the serials in the network). * * @returns A list of cube islands as graph nodes */ QList< QList< ControlCubeGraphNode * > > ControlNet::GetNodeConnections() const { QList< ControlCubeGraphNode * > notYetFound = cubeGraphNodes->values(); QList< QList< ControlCubeGraphNode * > > islands; do { // extract an island from the nodes which are not yet found QList< ControlCubeGraphNode * > island = RandomBFS(notYetFound); // remove newly found nodes from notYetFound for (int i = 0; i < island.size(); i++) notYetFound.removeOne(island[i]); // Add island to list of islands islands.append(island); } while (notYetFound.size()); return islands; } /** * @returns The total number of edges in the bi-directional graph for images */ Loading @@ -873,30 +734,6 @@ namespace Isis { } /** * Used for verifying graph intergrity * * @returns A string representation of the cube graph */ QString ControlNet::CubeGraphToString() const { QStringList serials; QHashIterator < QString, ControlCubeGraphNode * > i(*cubeGraphNodes); while (i.hasNext()) { i.next(); serials << i.value()->getSerialNumber(); } qSort(serials); QString str; for (int i = 0; i < serials.size(); i++) { str += " " + serials[i] + "\n" + (*cubeGraphNodes)[serials[i]]->connectionsToString() + "\n"; } return str; } /** * Use this method to get a complete list of all the cube serial numbers in * the network. Note that the order in which the serials are ordered in the Loading Loading @@ -1792,29 +1629,6 @@ namespace Isis { } const ControlCubeGraphNode *ControlNet::getGraphNode( QString serialNumber) const { if (!cubeGraphNodes->contains(serialNumber)) { IString msg = "Serial Number [" + serialNumber + "] does not exist in" " the network."; throw IException(IException::Programmer, msg, _FILEINFO_); } return cubeGraphNodes->value(serialNumber); } ControlCubeGraphNode *ControlNet::getGraphNode( QString serialNumber) { if (!cubeGraphNodes->contains(serialNumber)) { IString msg = "Serial Number [" + serialNumber + "] does not exist in" " the network."; throw IException(IException::Programmer, msg, _FILEINFO_); } return cubeGraphNodes->value(serialNumber); } /** * Get the target radii * Loading isis/src/control/objs/ControlNet/ControlNet.h +3 −12 Original line number Diff line number Diff line Loading @@ -214,7 +214,8 @@ namespace Isis { * @history 2018-01-26 Kristin Berry - Added pointAdded() function to eliminate redundant measure * adds to the control network. * @history 2018-01-26 Kristin Berry - Removed unused methods and associated code: * MinimumSpanningTree, * MinimumSpanningTree(), GetNodeConnections(), RandomBFS(), Shuffle(), * CalcBWAndCE(), CubeGraphToString(), getGraphNode() * */ class ControlNet : public QObject { Loading Loading @@ -245,9 +246,7 @@ namespace Isis { QList< QString > GetCubeSerials() const; QList< ControlCubeGraphNode * > GetCubeGraphNodes(); QList< QList< QString > > GetSerialConnections() const; QList< QList< ControlCubeGraphNode * > > GetNodeConnections() const; int getEdgeCount() const; QString CubeGraphToString() const; QList< ControlMeasure * > GetMeasuresInCube(QString serialNumber); QList< ControlMeasure * > GetValidMeasuresInCube(QString serialNumber); QList< ControlMeasure * > sortedMeasureList(double(ControlMeasure::*statFunc)() const, Loading @@ -262,9 +261,6 @@ namespace Isis { const ControlPoint *GetPoint(int index) const; ControlPoint *GetPoint(int index); const ControlCubeGraphNode *getGraphNode(QString serialNumber) const; ControlCubeGraphNode *getGraphNode(QString serialNumber); double AverageResidual(); Isis::Camera *Camera(int index); QString CreatedDate() const; Loading Loading @@ -333,11 +329,6 @@ namespace Isis { private: // graphing functions QList< ControlCubeGraphNode * > RandomBFS(QList < ControlCubeGraphNode * > list) const; void Shuffle(QList< ControlCubeGraphNode * > & list) const; QPair< int, int > CalcBWAndCE(QList< QString > serials) const; /** * @author 2012-04-13 Orrin Thomas * Loading isis/src/control/objs/ControlNet/unitTest.cpp +20 −15 Original line number Diff line number Diff line Loading @@ -145,14 +145,19 @@ void testConnectivity() { net.AddPoint(p4); net.AddPoint(p5); cout << "\nTesting GetNodeConnections()\n"; QList< QList< ControlCubeGraphNode * > > islands = net.GetNodeConnections(); if (islands[0].contains(m9->ControlSN())) islands.swap(0, 1); cout << " " << "Island Count = " << islands.size() << endl; // This region is to test the unused and now removed GetNodeConnections methods. It's tempoararily // left here commented out in case we want to test something similar after updating ControlNet to // use boost. //cout << "\nTesting GetNodeConnections()\n"; //QList< QList< ControlCubeGraphNode * > > islands = net.GetNodeConnections(); //if (islands[0].contains(m9->ControlSN())) islands.swap(0, 1); //cout << " " << "Island Count = " << islands.size() << endl; // This region all has to do with testing the (unused) removed MinimumSpanningTree // method. It's left in here commented-out for now in case we would like to test // island functionality here, using similar output, after updating ControlNet to use boost. //cout << "\nTesting MinimumSpanningTree()\n"; //QList< QSet< ControlMeasure * > > spanningTrees; //int nodeCount = 0; Loading Loading @@ -236,11 +241,11 @@ int main() { net.AddPoint(p0); // test ignoring of measures cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; p0m1->SetIgnored(true); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; p0m1->SetIgnored(false); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; // add another point - testing case where measures are added to points which // are already added to a net. Loading @@ -256,30 +261,30 @@ int main() { p1m2->SetCubeSerialNumber("CHARLIE"); p1->Add(p1m1); p1->Add(p1m2); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; // test ignoring of point cout << "testing setting point to ignored.......................\n"; p1->SetIgnored(true); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; p1->SetIgnored(false); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; // test measure deletion cout << "testing measure deletion & addition....................\n"; p0->Delete(p0m1); p0m1 = NULL; cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; p0m0 = new ControlMeasure; p0m0->SetCubeSerialNumber("DELTA"); p0->Add(p0m0); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; // test point deletion cout << "testing point deletion.................................\n"; net.DeletePoint(p1); p1 = NULL; cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; cout << "******* Done testing cube graph ***************\n\n\n"; Loading Loading @@ -549,8 +554,8 @@ int main() { cout << " " << sn << "\n"; } cout << "\nTesting getGraphNode: " << net.getGraphNode("ALPHA")->getSerialNumber() << "\n"; cout << "\nTesting getGraphNode: "; // << net.getGraphNode("ALPHA")->getSerialNumber() << "\n"; cout << "\nTesting getEdgeCount: " << net.getEdgeCount() << "\n"; Loading Loading
isis/src/control/objs/ControlNet/ControlNet.cpp +1 −187 Original line number Diff line number Diff line Loading @@ -616,113 +616,6 @@ namespace Isis { } /** * Random breadth-first search. This meathod starts at a random serial, and * returns a list with the start serial as well as any serial which is * directly or indirectly connected to it. The list returned will contain * all the serials in the network if and only if the network is completely * connected. Otherwise, the list returned will be the entire island on * which a random image resides. * * @returns A List of connected graph nodes */ QList< ControlCubeGraphNode * > ControlNet::RandomBFS( QList< ControlCubeGraphNode * > nodes) const { qsrand(42); Shuffle(nodes); // for keeping track of visited nodes QMap< ControlCubeGraphNode *, bool > searchList; for (int i = 0; i < nodes.size(); i++) searchList.insert(nodes[i], false); // for storing nodes as they are found QSet< ControlCubeGraphNode * > results; QQueue< ControlCubeGraphNode * > q; q.enqueue(nodes[0]); while (q.size()) { ControlCubeGraphNode *curNode = q.dequeue(); if (!results.contains(curNode)) { // add to results results.insert(curNode); searchList[curNode] = true; // add all the neighbors to the queue QList< ControlCubeGraphNode * > neighbors = curNode->getAdjacentNodes(); Shuffle(neighbors); for (int i = 0; i < neighbors.size(); i++) q.enqueue(neighbors[i]); } } // end of breadth-first search return results.values(); } /** * Shuffles the QStrings in a QList< QString > * * @param list The list to be shuffled */ void ControlNet::Shuffle(QList< ControlCubeGraphNode * > & list) const { for (int i = list.size() - 1; i > 0; i--) { // standard form is qrand() / (RAND_MAX + 1.0) * (max + 1 - min) + min // min is always zero here so it is simplified to... int j = (int)(qrand() / (RAND_MAX + 1.0) * (i + 1)); qSwap(list[j], list[i]); } } /** * Calculate the band width and critical edges needed by the adjacency matrix * that could store cube connectivity if that matrix used the same ordering * as is in the provided list. Note that no adjacency matrices are ever used * in this class! * * Critical edges are edges that contribute to band width. * * @param serials A list of cube serial numbers. * * @returns A QPair such that the first element is the needed bandwidth for * the serials how they are currently ordered in the list, and the * second element is the number of critical edges. */ QPair< int, int > ControlNet::CalcBWAndCE(QList< QString > serials) const { for (int i = 0; i < serials.size(); i++) ASSERT(cubeGraphNodes->contains(serials[i])); int bw = 0; QList< int > colWidths; for (int i = 0; i < serials.size(); i++) { int colWidth = 0; ControlCubeGraphNode *node1 = (*cubeGraphNodes)[serials[i]]; for (int j = 0; j < serials.size(); j++) { if (i != j) { ControlCubeGraphNode *node2 = (*cubeGraphNodes)[serials[j]]; int colDiff = abs(i - j); if (node1->isConnected(node2) && colDiff > colWidth) colWidth = colDiff; } } colWidths.append(colWidth); if (colWidth > bw) bw = colWidth; } int criticalEdges = 0; foreach(int width, colWidths) { if (width == bw) criticalEdges++; } return qMakePair(bw, criticalEdges); } /** * Delete a ControlPoint from the network by the point's address. * Loading Loading @@ -817,7 +710,7 @@ namespace Isis { */ QList< QList< QString > > ControlNet::GetSerialConnections() const { QList< QList< QString > > islandStrings; QList< QList< ControlCubeGraphNode * > > islands = GetNodeConnections(); QList< QList< ControlCubeGraphNode * > > islands; for (int i = 0; i < islands.size(); i++) { QList< QString > newIsland; islandStrings.append(newIsland); Loading @@ -828,38 +721,6 @@ namespace Isis { } /** * This method searches through all the cube serial numbers in the network. * Serials which are connected to other serials through points are grouped * together in the same lists. The list containing the lists of strings is * nothing more than a list of islands such that each island is a list of * serials which are connected to each other. If the control network is * completely connected, then this list will only have one element (a list * of all the serials in the network). * * @returns A list of cube islands as graph nodes */ QList< QList< ControlCubeGraphNode * > > ControlNet::GetNodeConnections() const { QList< ControlCubeGraphNode * > notYetFound = cubeGraphNodes->values(); QList< QList< ControlCubeGraphNode * > > islands; do { // extract an island from the nodes which are not yet found QList< ControlCubeGraphNode * > island = RandomBFS(notYetFound); // remove newly found nodes from notYetFound for (int i = 0; i < island.size(); i++) notYetFound.removeOne(island[i]); // Add island to list of islands islands.append(island); } while (notYetFound.size()); return islands; } /** * @returns The total number of edges in the bi-directional graph for images */ Loading @@ -873,30 +734,6 @@ namespace Isis { } /** * Used for verifying graph intergrity * * @returns A string representation of the cube graph */ QString ControlNet::CubeGraphToString() const { QStringList serials; QHashIterator < QString, ControlCubeGraphNode * > i(*cubeGraphNodes); while (i.hasNext()) { i.next(); serials << i.value()->getSerialNumber(); } qSort(serials); QString str; for (int i = 0; i < serials.size(); i++) { str += " " + serials[i] + "\n" + (*cubeGraphNodes)[serials[i]]->connectionsToString() + "\n"; } return str; } /** * Use this method to get a complete list of all the cube serial numbers in * the network. Note that the order in which the serials are ordered in the Loading Loading @@ -1792,29 +1629,6 @@ namespace Isis { } const ControlCubeGraphNode *ControlNet::getGraphNode( QString serialNumber) const { if (!cubeGraphNodes->contains(serialNumber)) { IString msg = "Serial Number [" + serialNumber + "] does not exist in" " the network."; throw IException(IException::Programmer, msg, _FILEINFO_); } return cubeGraphNodes->value(serialNumber); } ControlCubeGraphNode *ControlNet::getGraphNode( QString serialNumber) { if (!cubeGraphNodes->contains(serialNumber)) { IString msg = "Serial Number [" + serialNumber + "] does not exist in" " the network."; throw IException(IException::Programmer, msg, _FILEINFO_); } return cubeGraphNodes->value(serialNumber); } /** * Get the target radii * Loading
isis/src/control/objs/ControlNet/ControlNet.h +3 −12 Original line number Diff line number Diff line Loading @@ -214,7 +214,8 @@ namespace Isis { * @history 2018-01-26 Kristin Berry - Added pointAdded() function to eliminate redundant measure * adds to the control network. * @history 2018-01-26 Kristin Berry - Removed unused methods and associated code: * MinimumSpanningTree, * MinimumSpanningTree(), GetNodeConnections(), RandomBFS(), Shuffle(), * CalcBWAndCE(), CubeGraphToString(), getGraphNode() * */ class ControlNet : public QObject { Loading Loading @@ -245,9 +246,7 @@ namespace Isis { QList< QString > GetCubeSerials() const; QList< ControlCubeGraphNode * > GetCubeGraphNodes(); QList< QList< QString > > GetSerialConnections() const; QList< QList< ControlCubeGraphNode * > > GetNodeConnections() const; int getEdgeCount() const; QString CubeGraphToString() const; QList< ControlMeasure * > GetMeasuresInCube(QString serialNumber); QList< ControlMeasure * > GetValidMeasuresInCube(QString serialNumber); QList< ControlMeasure * > sortedMeasureList(double(ControlMeasure::*statFunc)() const, Loading @@ -262,9 +261,6 @@ namespace Isis { const ControlPoint *GetPoint(int index) const; ControlPoint *GetPoint(int index); const ControlCubeGraphNode *getGraphNode(QString serialNumber) const; ControlCubeGraphNode *getGraphNode(QString serialNumber); double AverageResidual(); Isis::Camera *Camera(int index); QString CreatedDate() const; Loading Loading @@ -333,11 +329,6 @@ namespace Isis { private: // graphing functions QList< ControlCubeGraphNode * > RandomBFS(QList < ControlCubeGraphNode * > list) const; void Shuffle(QList< ControlCubeGraphNode * > & list) const; QPair< int, int > CalcBWAndCE(QList< QString > serials) const; /** * @author 2012-04-13 Orrin Thomas * Loading
isis/src/control/objs/ControlNet/unitTest.cpp +20 −15 Original line number Diff line number Diff line Loading @@ -145,14 +145,19 @@ void testConnectivity() { net.AddPoint(p4); net.AddPoint(p5); cout << "\nTesting GetNodeConnections()\n"; QList< QList< ControlCubeGraphNode * > > islands = net.GetNodeConnections(); if (islands[0].contains(m9->ControlSN())) islands.swap(0, 1); cout << " " << "Island Count = " << islands.size() << endl; // This region is to test the unused and now removed GetNodeConnections methods. It's tempoararily // left here commented out in case we want to test something similar after updating ControlNet to // use boost. //cout << "\nTesting GetNodeConnections()\n"; //QList< QList< ControlCubeGraphNode * > > islands = net.GetNodeConnections(); //if (islands[0].contains(m9->ControlSN())) islands.swap(0, 1); //cout << " " << "Island Count = " << islands.size() << endl; // This region all has to do with testing the (unused) removed MinimumSpanningTree // method. It's left in here commented-out for now in case we would like to test // island functionality here, using similar output, after updating ControlNet to use boost. //cout << "\nTesting MinimumSpanningTree()\n"; //QList< QSet< ControlMeasure * > > spanningTrees; //int nodeCount = 0; Loading Loading @@ -236,11 +241,11 @@ int main() { net.AddPoint(p0); // test ignoring of measures cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; p0m1->SetIgnored(true); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; p0m1->SetIgnored(false); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; // add another point - testing case where measures are added to points which // are already added to a net. Loading @@ -256,30 +261,30 @@ int main() { p1m2->SetCubeSerialNumber("CHARLIE"); p1->Add(p1m1); p1->Add(p1m2); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; // test ignoring of point cout << "testing setting point to ignored.......................\n"; p1->SetIgnored(true); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; p1->SetIgnored(false); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; // test measure deletion cout << "testing measure deletion & addition....................\n"; p0->Delete(p0m1); p0m1 = NULL; cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; p0m0 = new ControlMeasure; p0m0->SetCubeSerialNumber("DELTA"); p0->Add(p0m0); cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; // test point deletion cout << "testing point deletion.................................\n"; net.DeletePoint(p1); p1 = NULL; cout << net.CubeGraphToString() << "\n"; // cout << net.CubeGraphToString() << "\n"; cout << "******* Done testing cube graph ***************\n\n\n"; Loading Loading @@ -549,8 +554,8 @@ int main() { cout << " " << sn << "\n"; } cout << "\nTesting getGraphNode: " << net.getGraphNode("ALPHA")->getSerialNumber() << "\n"; cout << "\nTesting getGraphNode: "; // << net.getGraphNode("ALPHA")->getSerialNumber() << "\n"; cout << "\nTesting getEdgeCount: " << net.getEdgeCount() << "\n"; Loading