MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / topoSort

Method topoSort

src/openms_gui/source/VISUAL/TOPPASScene.cpp:1453–1522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1451 }
1452
1453 void TOPPASScene::topoSort(bool resort_all)
1454 {
1455 UInt topo_counter {1};
1456 for (TOPPASVertex* tv : vertices_)
1457 {
1458 if (resort_all)
1459 {
1460 tv->setTopoSortMarked(false);
1461 }
1462 else if (tv->isTopoSortMarked())
1463 {
1464 ++topo_counter; // count number of existing/sorted vertices to get correct offset for new vertices
1465 }
1466 }
1467
1468 while (true)
1469 {
1470 bool some_vertex_not_finished = false;
1471 for (TOPPASVertex* tv : vertices_)
1472 {
1473 if (tv->isTopoSortMarked())
1474 {
1475 continue;
1476 }
1477
1478 bool has_unmarked_predecessors = false;
1479 for (TOPPASVertex::ConstEdgeIterator e_it = tv->inEdgesBegin(); e_it != tv->inEdgesEnd(); ++e_it)
1480 {
1481 TOPPASVertex* v = (*e_it)->getSourceVertex();
1482 if (!(v->isTopoSortMarked()))
1483 {
1484 has_unmarked_predecessors = true;
1485 break;
1486 }
1487 }
1488 if (has_unmarked_predecessors)
1489 { // needs to be revisited in the next round (where we hopefully have found the predecessors)
1490 some_vertex_not_finished = true;
1491 }
1492 else
1493 { // mark this node
1494 // update name of input node
1495 TOPPASInputFileListVertex* iflv = qobject_cast<TOPPASInputFileListVertex*>(tv);
1496 if (iflv)
1497 {
1498 //check if key was modified by user. if yes, don't update it
1499 QString old_topo_nr = QString::number(tv->getTopoNr());
1500 if (old_topo_nr == iflv->getKey() || iflv->getKey() == "")
1501 {
1502 iflv->setKey(QString::number(topo_counter));
1503 }
1504 }
1505
1506 tv->setTopoNr(topo_counter);
1507 tv->setTopoSortMarked(true);
1508
1509 ++topo_counter;
1510 }

Callers 1

insertNewVertex_Method · 0.80

Calls 12

numberFunction · 0.85
sortFunction · 0.85
setTopoSortMarkedMethod · 0.80
isTopoSortMarkedMethod · 0.80
inEdgesBeginMethod · 0.80
inEdgesEndMethod · 0.80
getSourceVertexMethod · 0.80
getTopoNrMethod · 0.80
setKeyMethod · 0.80
setTopoNrMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected