本文整理汇总了C++中SListPure::pushBack方法的典型用法代码示例。如果您正苦于以下问题:C++ SListPure::pushBack方法的具体用法?C++ SListPure::pushBack怎么用?C++ SListPure::pushBack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SListPure
的用法示例。
在下文中一共展示了SListPure::pushBack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractExternalSubgraph
// extracts and adds external subgraph from stopnode to ancestors of the node with dfi root
// to edgelist, nodeMarker is used as a visited flag. returns the endnode with lowest dfi.
void FindKuratowskis::extractExternalSubgraph(
const node stop,
int root,
SListPure<int>& externalStartnodes,
SListPure<node>& externalEndnodes)
{
int lowpoint;
ListConstIterator<node> it;
if (m_leastAncestor[stop] < root) {
externalStartnodes.pushBack(m_dfi[stop]);
externalEndnodes.pushBack(m_nodeFromDFI[m_leastAncestor[stop]]);
}
// descent to external active child bicomps of stopnode
node temp;
for (it = m_separatedDFSChildList[stop].begin(); it.valid(); ++it) {
temp = *it;
lowpoint = m_lowPoint[temp];
if (lowpoint >= root) break;
externalStartnodes.pushBack(m_dfi[temp]);
externalEndnodes.pushBack(m_nodeFromDFI[lowpoint]);
}
}
示例2: getFront
// The function front scans the frontier of nodePtr. It returns the keys
// of the leaves found in the frontier of nodePtr in a SListPure.
// These keys include keys of direction indicators detected in the frontier.
//
// No direction is assigned to the direction indicators.
//
void EmbedPQTree::getFront(
PQNode<edge,IndInfo*,bool>* nodePtr,
SListPure<PQBasicKey<edge,IndInfo*,bool>*> &keys)
{
ArrayBuffer<PQNode<edge,IndInfo*,bool>*> S;
S.push(nodePtr);
while (!S.empty())
{
PQNode<edge,IndInfo*,bool> *checkNode = S.popRet();
if (checkNode->type() == PQNodeRoot::PQNodeType::Leaf)
keys.pushBack((PQBasicKey<edge,IndInfo*,bool>*) checkNode->getKey());
else
{
PQNode<edge,IndInfo*,bool>* firstSon = nullptr;
if (checkNode->type() == PQNodeRoot::PQNodeType::PNode)
{
firstSon = checkNode->referenceChild();
}
else if (checkNode->type() == PQNodeRoot::PQNodeType::QNode)
{
firstSon = checkNode->getEndmost(PQNodeRoot::SibDirection::Right);
// By this, we make sure that we start on the left side
// since the left endmost child will be on top of the stack
}
if (firstSon->status() == PQNodeRoot::PQNodeStatus::Indicator)
{
keys.pushBack((PQBasicKey<edge,IndInfo*,bool>*) firstSon->getNodeInfo());
}
else
S.push(firstSon);
PQNode<edge,IndInfo*,bool> *nextSon = firstSon->getNextSib(nullptr);
PQNode<edge,IndInfo*,bool> *oldSib = firstSon;
while (nextSon && nextSon != firstSon)
{
if (nextSon->status() == PQNodeRoot::PQNodeStatus::Indicator)
keys.pushBack((PQBasicKey<edge,IndInfo*,bool>*) nextSon->getNodeInfo());
else
S.push(nextSon);
PQNode<edge,IndInfo*,bool> *holdSib = nextSon->getNextSib(oldSib);
oldSib = nextSon;
nextSon = holdSib;
}
}
}
}
示例3: getFront
// The function front scans the frontier of nodePtr. It returns the keys
// of the leaves found in the frontier of nodePtr in a SListPure.
// These keys include keys of direction indicators detected in the frontier.
//
// No direction is assigned to the direction indicators.
//
void EmbedPQTree::getFront(
PQNode<edge,indInfo*,bool>* nodePtr,
SListPure<PQBasicKey<edge,indInfo*,bool>*> &keys)
{
Stack<PQNode<edge,indInfo*,bool>*> S;
S.push(nodePtr);
while (!S.empty())
{
PQNode<edge,indInfo*,bool> *checkNode = S.pop();
if (checkNode->type() == PQNodeRoot::leaf)
keys.pushBack((PQBasicKey<edge,indInfo*,bool>*) checkNode->getKey());
else
{
PQNode<edge,indInfo*,bool>* firstSon = 0;
if (checkNode->type() == PQNodeRoot::PNode)
{
firstSon = checkNode->referenceChild();
}
else if (checkNode->type() == PQNodeRoot::QNode)
{
firstSon = checkNode->getEndmost(RIGHT);
// By this, we make sure that we start on the left side
// since the left endmost child will be on top of the stack
}
if (firstSon->status() == INDICATOR)
{
keys.pushBack((PQBasicKey<edge,indInfo*,bool>*) firstSon->getNodeInfo());
}
else
S.push(firstSon);
PQNode<edge,indInfo*,bool> *nextSon = firstSon->getNextSib(0);
PQNode<edge,indInfo*,bool> *oldSib = firstSon;
while (nextSon && nextSon != firstSon)
{
if (nextSon->status() == INDICATOR)
keys.pushBack((PQBasicKey<edge,indInfo*,bool>*) nextSon->getNodeInfo());
else
S.push(nextSon);
PQNode<edge,indInfo*,bool> *holdSib = nextSon->getNextSib(oldSib);
oldSib = nextSon;
nextSon = holdSib;
}
}
}
}
示例4: extractExternalSubgraphBundles
// extract and add external subgraph from stopnode to ancestors of the node with dfi root
// to edgelist, nodeMarker is used as a visited flag. returns the endnode with lowest dfi.
void FindKuratowskis::extractExternalSubgraphBundles(
const node stop,
int root,
SListPure<edge>& externalSubgraph,
int nodeMarker)
{
node v,temp;
adjEntry adj;
#ifdef OGDF_DEBUG
forall_nodes(v,m_g) OGDF_ASSERT(m_wasHere[v]!=nodeMarker);
#endif
StackPure<node> stack; // stack for dfs-traversal
ListConstIterator<node> it;
stack.push(stop);
while (!stack.empty()) {
v = stack.pop();
if (m_wasHere[v]==nodeMarker) continue;
// mark visited nodes
m_wasHere[v]=nodeMarker;
// search for unvisited nodes and add them to stack
forall_adj(adj,v) {
temp = adj->twinNode();
if (m_edgeType[adj->theEdge()]==EDGE_BACK_DELETED) continue;
// go along backedges to ancestor (ignore virtual nodes)
if (m_dfi[temp] < root && m_dfi[temp] > 0) {
OGDF_ASSERT(m_edgeType[adj->theEdge()]==EDGE_BACK);
externalSubgraph.pushBack(adj->theEdge());
} else if (v != stop && m_dfi[temp]>=m_dfi[v]) {
// set flag and push unvisited nodes
OGDF_ASSERT(m_edgeType[adj->theEdge()]==EDGE_BACK ||
m_edgeType[adj->theEdge()]==EDGE_DFS ||
m_edgeType[adj->theEdge()]==EDGE_BACK_DELETED);
externalSubgraph.pushBack(adj->theEdge());
if (m_wasHere[temp] != nodeMarker) stack.push(temp);
}
}
// descent to external active child bicomps
for (it = m_separatedDFSChildList[v].begin(); it.valid(); ++it) {
temp = *it;
if (m_lowPoint[temp] >= root) break;
stack.push(m_nodeFromDFI[-m_dfi[temp]]);
}
}
示例5: computeDFSChildLists
// compute the separated DFS children for all nodes in ascending order of
// their lowpoint values in linear time
void BoyerMyrvoldInit::computeDFSChildLists() {
// Bucketsort by lowpoint values
BucketLowPoint blp(m_lowPoint);
// copy all non-virtual nodes in a list and sort them with Bucketsort
SListPure<node> allNodes;
for (node v : m_g.nodes) {
if (m_dfi[v] > 0)
allNodes.pushBack(v);
}
allNodes.bucketSort(1, m_nodeFromDFI.high(), blp);
// build DFS-child list
for (node v : allNodes) {
OGDF_ASSERT(m_dfi[v] > 0);
// if node is not root: insert node after last element of parent's DFSChildList
// to achieve constant time deletion later:
// set a pointer for each node to predecessor of his representative in the list
if (m_adjParent[v] != nullptr) {
OGDF_ASSERT(m_realVertex[m_adjParent[v]->theNode()] != nullptr);
m_pNodeInParent[v] = m_separatedDFSChildList[m_realVertex[m_adjParent[v]->theNode()]].pushBack(v);
OGDF_ASSERT(m_pNodeInParent[v].valid());
OGDF_ASSERT(v == *m_pNodeInParent[v]);
}
else m_pNodeInParent[v] = nullptr;
}
}
示例6: Reduction
// Reduction reduced a set of leaves determined by their keys stored
// in leafKeys. Integer redNumber is for debugging only.
bool EmbedPQTree::Reduction(SListPure<PlanarLeafKey<IndInfo*>*> &leafKeys)
{
SListPure<PQLeafKey<edge, IndInfo*, bool>*> castLeafKeys;
for (PlanarLeafKey<IndInfo*> *key : leafKeys)
castLeafKeys.pushBack(static_cast<PQLeafKey<edge, IndInfo*, bool>*>(key));
return PQTree<edge, IndInfo*, bool>::Reduction(castLeafKeys);
}
示例7: Initialize
// Initializes a PQTree by a set of leaves that will korrespond to
// the set of Keys stored in leafKeys.
int PlanarPQTree::Initialize(SListPure<PlanarLeafKey<IndInfo*>*> &leafKeys)
{
SListIterator<PlanarLeafKey<IndInfo*>* > it;
SListPure<PQLeafKey<edge,IndInfo*,bool>*> castLeafKeys;
for (it = leafKeys.begin(); it.valid(); ++it)
castLeafKeys.pushBack((PQLeafKey<edge,IndInfo*,bool>*) *it);
return PQTree<edge,IndInfo*,bool>::Initialize(castLeafKeys);
}
示例8: Reduction
// Reduction reduced a set of leaves determined by their keys stored
// in leafKeys. Integer redNumber is for debugging only.
bool PlanarPQTree::Reduction(SListPure<PlanarLeafKey<indInfo*>*> &leafKeys)
{
SListIterator<PlanarLeafKey<indInfo*>* > it;
SListPure<PQLeafKey<edge,indInfo*,bool>*> castLeafKeys;
for (it = leafKeys.begin(); it.valid(); ++it)
castLeafKeys.pushBack((PQLeafKey<edge,indInfo*,bool>*) *it);
return PQTree<edge,indInfo*,bool>::Reduction(castLeafKeys);
}
示例9: doInit
void FaceSinkGraph::doInit()
{
const ConstCombinatorialEmbedding &E = *m_pE;
NodeArray<node> sinkSwitch(E,nullptr); // corresponding node in F (if any)
NodeArray<bool> isSinkSwitch(E,true);
NodeArray<int> visited(E,-1);
int faceNo = -1;
for(face f : E.faces)
{
faceNo++;
node faceNode = newNode();
m_originalFace[faceNode] = f;
SListPure<node> nodesInF;
adjEntry adj1 = f->firstAdj(), adj = adj1;
do {
node v = adj->theNode();
// if the graph is not biconnected, then node v can visited more than once
if (visited[v] != faceNo) {
nodesInF.pushBack(v);
visited[v] = faceNo;
}
if (v == m_source)
m_containsSource[faceNode] = true;
isSinkSwitch[adj->theEdge()->source()] = false;
adj = adj->twin()->cyclicPred();
} while (adj != adj1);
SListConstIterator<node> it;
for(it = nodesInF.begin(); it.valid(); ++it)
{
node v = *it;
if(isSinkSwitch[v]) {
if (sinkSwitch[v] == nullptr) {
node vF = newNode();
m_originalNode[vF] = v;
sinkSwitch[v] = vF;
}
newEdge(faceNode,sinkSwitch[v]);
}
}
for(it = nodesInF.begin(); it.valid(); ++it)
isSinkSwitch[*it] = true;
}
}
示例10: setPosInEmbedding
void PlanarSPQRTree::setPosInEmbedding(
NodeArray<SListPure<adjEntry> > &adjEdges,
NodeArray<node> ¤tCopy,
NodeArray<adjEntry> &lastAdj,
SListPure<node> ¤t,
const Skeleton &S,
adjEntry adj)
{
node vT = S.treeNode();
adjEdges[vT].pushBack(adj);
node vCopy = adj->theNode();
node vOrig = S.original(vCopy);
if(currentCopy[vT] == nullptr) {
currentCopy[vT] = vCopy;
current.pushBack(vT);
for (adjEntry adjVirt : vCopy->adjEdges) {
edge eCopy = S.twinEdge(adjVirt->theEdge());
if (eCopy == nullptr) continue;
if (adjVirt == adj) {
lastAdj[vT] = adj;
continue;
}
const Skeleton &STwin = skeleton(S.twinTreeNode(adjVirt->theEdge()));
adjEntry adjCopy = (STwin.original(eCopy->source()) == vOrig) ?
eCopy->adjSource() : eCopy->adjTarget();
setPosInEmbedding(adjEdges,currentCopy,lastAdj,current,
STwin, adjCopy);
}
} else if (lastAdj[vT] != nullptr && lastAdj[vT] != adj) {
adjEntry adjVirt = lastAdj[vT];
edge eCopy = S.twinEdge(adjVirt->theEdge());
const Skeleton &STwin = skeleton(S.twinTreeNode(adjVirt->theEdge()));
adjEntry adjCopy = (STwin.original(eCopy->source()) == vOrig) ?
eCopy->adjSource() : eCopy->adjTarget();
setPosInEmbedding(adjEdges,currentCopy,lastAdj,current,
STwin, adjCopy);
lastAdj[vT] = nullptr;
}
}
示例11: ReplaceRoot
void EmbedPQTree::ReplaceRoot(
SListPure<PlanarLeafKey<indInfo*>*> &leafKeys,
SListPure<edge> &frontier,
SListPure<node> &opposed,
SListPure<node> &nonOpposed,
node v)
{
SListPure<PQBasicKey<edge,indInfo*,bool>*> nodeFrontier;
if (leafKeys.empty() && m_pertinentRoot == m_root)
{
front(m_pertinentRoot,nodeFrontier);
m_pertinentRoot = 0; // check for this emptyAllPertinentNodes
} else {
if (m_pertinentRoot->status() == FULL)
ReplaceFullRoot(leafKeys,nodeFrontier,v);
else
ReplacePartialRoot(leafKeys,nodeFrontier,v);
}
// Check the frontier and get the direction indicators.
while (!nodeFrontier.empty())
{
PQBasicKey<edge,indInfo*,bool>* entry = nodeFrontier.popFrontRet();
if (entry->userStructKey()) // is a regular leaf
frontier.pushBack(entry->userStructKey());
else if (entry->userStructInfo()) {
if (entry->userStructInfo()->changeDir)
opposed.pushBack(entry->userStructInfo()->v);
else
nonOpposed.pushBack(entry->userStructInfo()->v);
}
}
}
示例12: getRootedPath
node PivotMDS::getRootedPath(const Graph& G)
{
node head = nullptr;
NodeArray<bool> visited(G, false);
SListPure<node> neighbors;
// in every path there are two nodes with degree 1 and
// each node has at most degree 2
for(node v : G.nodes)
{
int degree = 0;
visited[v] = true;
neighbors.pushBack(v);
for(adjEntry adj : v->adjEntries) {
node w = adj->twinNode();
if (!visited[w])
{
neighbors.pushBack(w);
visited[w]=true;
++degree;
}
}
if (degree > 2) {
neighbors.clear();
return nullptr;
}
if (degree == 1) {
head = v;
}
for(node u : neighbors) {
visited[u] = false;
}
neighbors.clear();
}
return head;
}
示例13: if
// Function ReplaceFullRoot either replaces the full root
// or one full child of a partial root of a pertinent subtree
// by a single P-node with leaves corresponding the keys stored in leafKeys.
void PlanarSubgraphPQTree::
ReplaceFullRoot(SListPure<PlanarLeafKey<whaInfo*>*> &leafKeys)
{
PQLeaf<edge,whaInfo*,bool> *leafPtr = 0; // dummy
PQInternalNode<edge,whaInfo*,bool> *nodePtr = 0; // dummy
//PQNodeKey<edge,whaInfo*,bool> *nodeInfoPtr = 0; // dummy
PQNode<edge,whaInfo*,bool> *currentNode = 0; // dummy
SListIterator<PlanarLeafKey<whaInfo*>* > it;
if (!leafKeys.empty() && leafKeys.front() == leafKeys.back())
{
//ReplaceFullRoot: replace pertinent root by a single leaf
leafPtr = OGDF_NEW PQLeaf<edge,whaInfo*,bool>(m_identificationNumber++,
EMPTY,(PQLeafKey<edge,whaInfo*,bool>*)leafKeys.front());
exchangeNodes(m_pertinentRoot,(PQNode<edge,whaInfo*,bool>*) leafPtr);
if (m_pertinentRoot == m_root)
m_root = (PQNode<edge,whaInfo*,bool>*) leafPtr;
}
else if (!leafKeys.empty()) // at least two leaves
{
//replace pertinent root by a $P$-node
if ((m_pertinentRoot->type() == P_NODE) ||
(m_pertinentRoot->type() == Q_NODE))
{
nodePtr = (PQInternalNode<edge,whaInfo*,bool>*)m_pertinentRoot;
nodePtr->type(P_NODE);
nodePtr->status(PERTROOT);
nodePtr->childCount(0);
while (!fullChildren(m_pertinentRoot)->empty())
{
currentNode = fullChildren(m_pertinentRoot)->popFrontRet();
removeChildFromSiblings(currentNode);
}
}
else if (m_pertinentRoot->type() == LEAF)
{
nodePtr = OGDF_NEW PQInternalNode<edge,whaInfo*,bool>(m_identificationNumber++,
P_NODE,EMPTY);
exchangeNodes(m_pertinentRoot,nodePtr);
}
SListPure<PQLeafKey<edge,whaInfo*,bool>*> castLeafKeys;
for (it = leafKeys.begin(); it.valid(); ++it)
castLeafKeys.pushBack((PQLeafKey<edge,whaInfo*,bool>*) *it);
addNewLeavesToTree(nodePtr,castLeafKeys);
}
}
示例14: doInit
void FaceSinkGraph::doInit()
{
const ConstCombinatorialEmbedding &E = *m_pE;
NodeArray<node> sinkSwitch(E,0); // corresponding node in F (if any)
NodeArray<bool> isSinkSwitch(E,true);
face f;
forall_faces(f,E)
{
node faceNode = newNode();
m_originalFace[faceNode] = f;
SListPure<node> nodesInF;
adjEntry adj1 = f->firstAdj(), adj = adj1;
do {
node v = adj->theNode();
nodesInF.pushBack(v);
if (v == m_source)
m_containsSource[faceNode] = true;
isSinkSwitch[adj->theEdge()->source()] = false;
adj = adj->twin()->cyclicPred();
} while (adj != adj1);
SListConstIterator<node> it;
for(it = nodesInF.begin(); it.valid(); ++it)
{
node v = *it;
if(isSinkSwitch[v]) {
if (sinkSwitch[v] == 0) {
node vF = newNode();
m_originalNode[vF] = v;
sinkSwitch[v] = vF;
}
newEdge(faceNode,sinkSwitch[v]);
}
}
for(it = nodesInF.begin(); it.valid(); ++it)
isSinkSwitch[*it] = true;
}
示例15: dfsBuildSpanningTree
void UpwardPlanarSubgraphSimple::dfsBuildSpanningTree(
node v,
SListPure<edge> &treeEdges,
NodeArray<bool> &visited)
{
visited[v] = true;
for(adjEntry adj : v->adjEntries) {
edge e = adj->theEdge();
node w = e->target();
if(w == v) continue;
if(!visited[w]) {
treeEdges.pushBack(e);
dfsBuildSpanningTree(w,treeEdges,visited);
}
}
}