本文整理汇总了C++中SListPure::permute方法的典型用法代码示例。如果您正苦于以下问题:C++ SListPure::permute方法的具体用法?C++ SListPure::permute怎么用?C++ SListPure::permute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SListPure
的用法示例。
在下文中一共展示了SListPure::permute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeDFS
// start DFS-traversal
void BoyerMyrvoldInit::computeDFS()
{
// compute random edge costs
EdgeArray<int> costs;
EdgeComparer comp;
if(m_randomness > 0 && m_edgeCosts != nullptr) {
costs.init(m_g);
int minCost = std::numeric_limits<int>::max();
int maxCost = std::numeric_limits<int>::min();
for(edge e : m_g.edges) {
minCost = min(minCost, (*m_edgeCosts)[e]);
maxCost = min(maxCost, (*m_edgeCosts)[e]);
}
std::uniform_real_distribution<> urd(-1, 1);
for(edge e : m_g.edges) {
costs[e] = minCost + (int)((1 - m_randomness) * ((*m_edgeCosts)[e] - minCost) + m_randomness * (maxCost - minCost) * urd(m_rand));
}
comp.setCosts(&costs);
} else if(m_edgeCosts != nullptr) {
comp.setCosts(m_edgeCosts);
}
StackPure<adjEntry> stack;
int nextDFI = 1;
const int numberOfNodes = m_g.numberOfNodes();
SListPure<adjEntry> adjList;
SListPure<node> list;
m_g.allNodes(list);
// get random dfs-tree, if wanted
if (m_randomness > 0) {
list.permute();
}
for (node v : list) {
if (v->degree() == 0) {
m_dfi[v] = nextDFI;
m_leastAncestor[v] = nextDFI;
m_nodeFromDFI[nextDFI] = v;
++nextDFI;
} else {
adjList.clear();
m_g.adjEntries(v, adjList);
adjList.quicksort(comp);
m_g.sort(v, adjList);
stack.push(v->firstAdj());
}
}
while (nextDFI <= numberOfNodes) {
OGDF_ASSERT(!stack.empty());
adjEntry prnt = stack.pop();
node v = prnt->theNode();
// check, if node v was visited before.
if (m_dfi[v] != 0) continue;
// parentNode=nullptr on first node on connected component
node parentNode = prnt->twinNode();
if (m_dfi[parentNode] == 0) parentNode = nullptr;
// if not, mark node as visited and initialize NodeArrays
m_dfi[v] = nextDFI;
m_leastAncestor[v] = nextDFI;
m_nodeFromDFI[nextDFI] = v;
++nextDFI;
// push all adjacent nodes onto stack
for(adjEntry adj : v->adjEdges) {
edge e = adj->theEdge();
if (adj == prnt && parentNode != nullptr) continue;
// check for self-loops and dfs- and dfs-parallel edges
node w = adj->twinNode();
if (m_dfi[w] == 0) {
m_edgeType[e] = EDGE_DFS;
m_adjParent[w] = adj;
m_link[CW][w] = adj;
m_link[CCW][w] = adj;
// found new dfs-edge: preorder
stack.push(adj->twin());
} else if (w == v) {
// found self-loop
m_edgeType[e] = EDGE_SELFLOOP;
} else {
// node w already has been visited and is an dfs-ancestor of v
OGDF_ASSERT(m_dfi[w] < m_dfi[v]);
if (w == parentNode) {
// found parallel edge of dfs-parent-edge
m_edgeType[e] = EDGE_DFS_PARALLEL;
} else {
// found backedge
m_edgeType[e] = EDGE_BACK;
// set least Ancestor
//.........这里部分代码省略.........