int main(void){ SList<int> mylist; mylist.pushFront(10); mylist.pushFront(20); mylist.pushBack(30); for(auto it=mylist.begin();it!=mylist.end();++it){ cout << *it << endl; } return 0; }
void FixEdgeInserterCore::findWeightedShortestPath(const CombinatorialEmbedding &E, edge eOrig, SList<adjEntry> &crossed) { node s = m_pr.copy(eOrig->source()); node t = m_pr.copy(eOrig->target()); OGDF_ASSERT(s != t); int eSubgraph = (m_pSubgraph != nullptr) ? (*m_pSubgraph)[eOrig] : 0; EdgeArray<int> costDual(m_dual, 0); int maxCost = 0; for(edge eDual : m_dual.edges) { int c = getCost(m_primalAdj[eDual]->theEdge(), eSubgraph); costDual[eDual] = c; if (c > maxCost) maxCost = c; } ++maxCost; Array<SListPure<edge> > nodesAtDist(maxCost); NodeArray<edge> spPred(m_dual,nullptr); int oldIdCount = m_dual.maxEdgeIndex(); // augment dual by edges from s to all adjacent faces of s ... for(adjEntry adj : s->adjEdges) { // starting edges of bfs-search are all edges leaving s edge eDual = m_dual.newEdge(m_vS, m_nodeOf[E.rightFace(adj)]); m_primalAdj[eDual] = adj; nodesAtDist[0].pushBack(eDual); } // ... and from all adjacent faces of t to t for(adjEntry adj : t->adjEdges) { edge eDual = m_dual.newEdge(m_nodeOf[E.rightFace(adj)], m_vT); m_primalAdj[eDual] = adj; } // actual search (using extended bfs on directed dual) int currentDist = 0; for( ; ; ) { // next candidate edge while(nodesAtDist[currentDist % maxCost].empty()) ++currentDist; edge eCand = nodesAtDist[currentDist % maxCost].popFrontRet(); node v = eCand->target(); // leads to an unvisited node? if (spPred[v] == nullptr) { // yes, then we set v's predecessor in search tree spPred[v] = eCand; // have we reached t ... if (v == m_vT) { // ... then search is done. // constructed list of used edges (translated to crossed // adjacency entries in PG) from t back to s (including first // and last!) do { edge eDual = spPred[v]; crossed.pushFront(m_primalAdj[eDual]); v = eDual->source(); } while(v != m_vS); break; } // append next candidate edges to queue (all edges leaving v) appendCandidates(nodesAtDist, costDual, maxCost, v, currentDist); } } // remove augmented edges again adjEntry adj; while ((adj = m_vS->firstAdj()) != nullptr) m_dual.delEdge(adj->theEdge()); while ((adj = m_vT->firstAdj()) != nullptr) m_dual.delEdge(adj->theEdge()); m_dual.resetEdgeIdCount(oldIdCount); }
void FixEdgeInserterCore::findShortestPath(const CombinatorialEmbedding &E, edge eOrig, SList<adjEntry> &crossed) { node s = m_pr.copy(eOrig->source()); node t = m_pr.copy(eOrig->target()); OGDF_ASSERT(s != t); NodeArray<edge> spPred(m_dual,nullptr); QueuePure<edge> queue; int oldIdCount = m_dual.maxEdgeIndex(); // augment dual by edges from s to all adjacent faces of s ... for(adjEntry adj : s->adjEdges) { // starting edges of bfs-search are all edges leaving s edge eDual = m_dual.newEdge(m_vS, m_nodeOf[E.rightFace(adj)]); m_primalAdj[eDual] = adj; queue.append(eDual); } // ... and from all adjacent faces of t to t for(adjEntry adj : t->adjEdges) { edge eDual = m_dual.newEdge(m_nodeOf[E.rightFace(adj)], m_vT); m_primalAdj[eDual] = adj; } // actual search (using bfs on directed dual) for( ; ;) { // next candidate edge edge eCand = queue.pop(); node v = eCand->target(); // leads to an unvisited node? if (spPred[v] == nullptr) { // yes, then we set v's predecessor in search tree spPred[v] = eCand; // have we reached t ... if (v == m_vT) { // ... then search is done. // constructed list of used edges (translated to crossed // adjacency entries in PG) from t back to s (including first // and last!) do { edge eDual = spPred[v]; crossed.pushFront(m_primalAdj[eDual]); v = eDual->source(); } while(v != m_vS); break; } // append next candidate edges to queue (all edges leaving v) appendCandidates(queue, v); } } // remove augmented edges again adjEntry adj; while ((adj = m_vS->firstAdj()) != nullptr) m_dual.delEdge(adj->theEdge()); while ((adj = m_vT->firstAdj()) != nullptr) m_dual.delEdge(adj->theEdge()); m_dual.resetEdgeIdCount(oldIdCount); }