本文整理汇总了C++中SListPure::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ SListPure::begin方法的具体用法?C++ SListPure::begin怎么用?C++ SListPure::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SListPure
的用法示例。
在下文中一共展示了SListPure::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2:
void SubgraphPlanarizer::CrossingStructure::restore(PlanRep &PG, int cc)
{
//PG.initCC(cc);
Array<node> id2Node(0,m_numCrossings-1,0);
SListPure<edge> edges;
PG.allEdges(edges);
for(SListConstIterator<edge> itE = edges.begin(); itE.valid(); ++itE)
{
edge ePG = *itE;
edge e = PG.original(ePG);
SListConstIterator<int> it;
for(it = m_crossings[e].begin(); it.valid(); ++it)
{
node x = id2Node[*it];
edge ePGOld = ePG;
ePG = PG.split(ePG);
node y = ePG->source();
if(x == 0) {
id2Node[*it] = y;
} else {
PG.moveTarget(ePGOld, x);
PG.moveSource(ePG, x);
PG.delNode(y);
}
}
}
}
示例3: 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;
}
示例4: 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);
}
示例5: 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);
}
示例6: call
void UpwardPlanarSubgraphSimple::call(const Graph &G, List<edge> &delEdges)
{
delEdges.clear();
// We construct an auxiliary graph H which represents the current upward
// planar subgraph.
Graph H;
NodeArray<node> mapToH(G);
for(node v : G.nodes)
mapToH[v] = H.newNode();
// We currently support only single-source acyclic digraphs ...
node s;
hasSingleSource(G,s);
OGDF_ASSERT(s != 0);
OGDF_ASSERT(isAcyclic(G));
// We start with a spanning tree of G rooted at the single source.
NodeArray<bool> visitedNode(G,false);
SListPure<edge> treeEdges;
dfsBuildSpanningTree(s,treeEdges,visitedNode);
// Mark all edges in the spanning tree so they can be skipped in the
// loop below and add (copies of) them to H.
EdgeArray<bool> visitedEdge(G,false);
SListConstIterator<edge> it;
for(it = treeEdges.begin(); it.valid(); ++it) {
edge eG = *it;
visitedEdge[eG] = true;
H.newEdge(mapToH[eG->source()],mapToH[eG->target()]);
}
// Add subsequently the remaining edges to H and test if the resulting
// graph is still upward planar. If not, remove the edge again from H
// and add it to delEdges.
for(edge eG : G.edges)
{
if(visitedEdge[eG] == true)
continue;
edge eH = H.newEdge(mapToH[eG->source()],mapToH[eG->target()]);
if (UpwardPlanarity::isUpwardPlanar_singleSource(H) == false) {
H.delEdge(eH);
delEdges.pushBack(eG);
}
}
}
示例7: Reduce
// Reduction reduced a set of leaves determined by their keys stored
// in leafKeys. Integer redNumber is for debugging only.
bool PlanarSubgraphPQTree::
Reduction(SListPure<PlanarLeafKey<whaInfo*>*> &leafKeys,
SList<PQLeafKey<edge,whaInfo*,bool>*> &eliminatedKeys,
int redNumber)
{
SListPure<PQLeafKey<edge,whaInfo*,bool>*> castLeafKeys;
SListIterator<PlanarLeafKey<whaInfo*>* > it;
for (it = leafKeys.begin(); it.valid(); ++it)
{
castLeafKeys.pushBack((PQLeafKey<edge,whaInfo*,bool>*) *it);
#ifdef OGDF_DEBUG
if (int(ogdf::debugLevel) >= int(dlHeavyChecks))
{
cout << (*it)->print() << endl;
}
#endif
}
determineMinRemoveSequence(castLeafKeys,eliminatedKeys);
removeEliminatedLeaves(eliminatedKeys);
SListIterator<PQLeafKey<edge,whaInfo*,bool>* > itn = castLeafKeys.begin();
SListIterator<PQLeafKey<edge,whaInfo*,bool>* > itp = itn++;
for (; itn.valid();)
{
if ((*itn)->nodePointer()->status()== WHA_DELETE)
{
itn++;
castLeafKeys.delSucc(itp);
}
else
itp = itn++;
}
if ((*castLeafKeys.begin())->nodePointer()->status() == WHA_DELETE)
castLeafKeys.popFront();
return Reduce(castLeafKeys,redNumber);
}
示例8: 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);
}
}
示例9: isParallelFree
bool isParallelFree(const Graph &G)
{
if (G.numberOfEdges() <= 1) return true;
SListPure<edge> edges;
parallelFreeSort(G,edges);
SListConstIterator<edge> it = edges.begin();
edge ePrev = *it, e;
for(it = ++it; it.valid(); ++it, ePrev = e) {
e = *it;
if (ePrev->source() == e->source() && ePrev->target() == e->target())
return false;
}
return true;
}
示例10: numParallelEdges
int numParallelEdges(const Graph &G)
{
if (G.numberOfEdges() <= 1) return 0;
SListPure<edge> edges;
parallelFreeSort(G,edges);
int num = 0;
SListConstIterator<edge> it = edges.begin();
edge ePrev = *it, e;
for(it = ++it; it.valid(); ++it, ePrev = e) {
e = *it;
if (ePrev->source() == e->source() && ePrev->target() == e->target())
++num;
}
return num;
}
示例11: isParallelFreeUndirected
bool isParallelFreeUndirected(const Graph &G)
{
if (G.numberOfEdges() <= 1) return true;
SListPure<edge> edges;
EdgeArray<int> minIndex(G), maxIndex(G);
parallelFreeSortUndirected(G,edges,minIndex,maxIndex);
SListConstIterator<edge> it = edges.begin();
edge ePrev = *it, e;
for(it = ++it; it.valid(); ++it, ePrev = e) {
e = *it;
if (minIndex[ePrev] == minIndex[e] && maxIndex[ePrev] == maxIndex[e])
return false;
}
return true;
}
示例12: ReplaceFullRoot
// 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 PlanarPQTree::ReplaceFullRoot(SListPure<PlanarLeafKey<indInfo*>*> &leafKeys)
{
if (!leafKeys.empty() && leafKeys.front() == leafKeys.back())
{
//ReplaceFullRoot: replace pertinent root by a single leaf
PQLeaf<edge,indInfo*,bool> *leafPtr =
OGDF_NEW PQLeaf<edge,indInfo*,bool>(m_identificationNumber++,
EMPTY,(PQLeafKey<edge,indInfo*,bool>*)leafKeys.front());
exchangeNodes(m_pertinentRoot,(PQNode<edge,indInfo*,bool>*) leafPtr);
if (m_pertinentRoot == m_root)
m_root = (PQNode<edge,indInfo*,bool>*) leafPtr;
m_pertinentRoot = 0; // check for this emptyAllPertinentNodes
}
else if (!leafKeys.empty()) // at least two leaves
{
PQInternalNode<edge,indInfo*,bool> *nodePtr = 0; // dummy
//replace pertinent root by a $P$-node
if ((m_pertinentRoot->type() == PQNodeRoot::PNode) ||
(m_pertinentRoot->type() == PQNodeRoot::QNode))
{
nodePtr = (PQInternalNode<edge,indInfo*,bool>*)m_pertinentRoot;
nodePtr->type(PQNodeRoot::PNode);
nodePtr->childCount(0);
while (!fullChildren(m_pertinentRoot)->empty())
removeChildFromSiblings(fullChildren(m_pertinentRoot)->popFrontRet());
}
else if (m_pertinentRoot->type() == PQNodeRoot::leaf)
{
nodePtr = OGDF_NEW PQInternalNode<edge,indInfo*,bool>(m_identificationNumber++,
PQNodeRoot::PNode,EMPTY);
exchangeNodes(m_pertinentRoot,nodePtr);
m_pertinentRoot = 0; // check for this emptyAllPertinentNodes
}
SListPure<PQLeafKey<edge,indInfo*,bool>*> castLeafKeys;
SListIterator<PlanarLeafKey<indInfo*>* > it;
for (it = leafKeys.begin(); it.valid(); ++it)
castLeafKeys.pushBack((PQLeafKey<edge,indInfo*,bool>*) *it);
addNewLeavesToTree(nodePtr,castLeafKeys);
}
}
示例13: init
// builds expansion graph of i-th biconnected component of the original graph
void ExpansionGraph::init(int i)
{
OGDF_ASSERT(0 <= i);
OGDF_ASSERT(i <= m_component.high());
// remove previous component
for(node v : nodes) {
node vOrig = m_vOrig[v];
if (vOrig)
m_vCopy[vOrig] = nullptr;
}
clear();
// create new component
SListConstIterator<edge> it;
for(it = m_component[i].begin(); it.valid(); ++it)
{
edge e = *it;
edge eCopy = newEdge(getCopy(e->source()),getCopy(e->target()));
m_eOrig[eCopy] = e;
}
// expand vertices
for(node v : nodes)
{
if (original(v) && v->indeg() >= 1 && v->outdeg() >= 1) {
node vPrime = newNode();
m_vRep[vPrime] = m_vOrig[v];
SListPure<edge> edges;
v->outEdges(edges);
SListConstIterator<edge> it;
for(it = edges.begin(); it.valid(); ++it)
moveSource(*it,vPrime);
newEdge(v,vPrime);
}
}
}
示例14: checkAcyclic
// test if graphAcyclicTest plus edges in tmpAugmented is acyclic
// removes added edges again
bool UpwardPlanarSubgraphSimple::checkAcyclic(
GraphCopySimple &graphAcyclicTest,
SList<Tuple2<node,node> > &tmpAugmented)
{
SListPure<edge> added;
SListConstIterator<Tuple2<node,node> > it;
for(it = tmpAugmented.begin(); it.valid(); ++it)
added.pushBack(graphAcyclicTest.newEdge(
graphAcyclicTest.copy((*it).x1()),
graphAcyclicTest.copy((*it).x2())));
bool acyclic = isAcyclic(graphAcyclicTest);
SListConstIterator<edge> itE;
for(itE = added.begin(); itE.valid(); ++itE)
graphAcyclicTest.delEdge(*itE);
return acyclic;
}
示例15: stAugmentation
// original variant of st-augmentation
// Inserts also new nodes representing faces into G.
void FaceSinkGraph::stAugmentation(
node h, // node corresponding to external face
Graph &G, // original graph (not const)
SList<node> &augmentedNodes, // list of augmented nodes
SList<edge> &augmentedEdges) // list of augmented edges
{
SListPure<node> roots;
for(node v : nodes) {
node vOrig = m_originalNode[v];
if (vOrig != nullptr && vOrig->indeg() > 0 && vOrig->outdeg() > 0)
roots.pushBack(v);
}
node vh = dfsStAugmentation(h,nullptr,G,augmentedNodes,augmentedEdges);
SListConstIterator<node> it;
for(it = roots.begin(); it.valid(); ++it)
dfsStAugmentation(*it,nullptr,G,augmentedNodes,augmentedEdges);
augmentedEdges.pushBack(G.newEdge(m_source,vh));
}