本文整理汇总了C++中SList::permute方法的典型用法代码示例。如果您正苦于以下问题:C++ SList::permute方法的具体用法?C++ SList::permute怎么用?C++ SList::permute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SList
的用法示例。
在下文中一共展示了SList::permute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: call
void GEMLayout::call(GraphAttributes &AG)
{
const Graph &G = AG.constGraph();
if(G.empty())
return;
// all edges straight-line
AG.clearAllBends();
GraphCopy GC;
GC.createEmpty(G);
// compute connected component of G
NodeArray<int> component(G);
int numCC = connectedComponents(G,component);
// intialize the array of lists of nodes contained in a CC
Array<List<node> > nodesInCC(numCC);
for(node v : G.nodes)
nodesInCC[component[v]].pushBack(v);
EdgeArray<edge> auxCopy(G);
Array<DPoint> boundingBox(numCC);
int i;
for(i = 0; i < numCC; ++i)
{
GC.initByNodes(nodesInCC[i],auxCopy);
GraphCopyAttributes AGC(GC,AG);
for(node vCopy : GC.nodes) {
node vOrig = GC.original(vCopy);
AGC.x(vCopy) = AG.x(vOrig);
AGC.y(vCopy) = AG.y(vOrig);
}
SList<node> permutation;
// initialize node data
m_impulseX.init(GC,0);
m_impulseY.init(GC,0);
m_skewGauge.init(GC,0);
m_localTemperature.init(GC,m_initialTemperature);
// initialize other data
m_globalTemperature = m_initialTemperature;
m_barycenterX = 0;
m_barycenterY = 0;
for(node v : GC.nodes) {
m_barycenterX += weight(v) * AGC.x(v);
m_barycenterY += weight(v) * AGC.y(v);
}
m_cos = cos(m_oscillationAngle / 2.0);
m_sin = sin(Math::pi / 2 + m_rotationAngle / 2.0);
// main loop
int counter = m_numberOfRounds;
while(OGDF_GEOM_ET.greater(m_globalTemperature,m_minimalTemperature) && counter--) {
// choose nodes by random permutations
if(permutation.empty()) {
for(node v : GC.nodes)
permutation.pushBack(v);
permutation.permute(m_rng);
}
node v = permutation.popFrontRet();
// compute the impulse of node v
computeImpulse(GC,AGC,v);
// update node v
updateNode(GC,AGC,v);
}
node vFirst = GC.firstNode();
double minX = AGC.x(vFirst), maxX = AGC.x(vFirst),
minY = AGC.y(vFirst), maxY = AGC.y(vFirst);
for(node vCopy : GC.nodes) {
node v = GC.original(vCopy);
AG.x(v) = AGC.x(vCopy);
AG.y(v) = AGC.y(vCopy);
if(AG.x(v)-AG.width (v)/2 < minX) minX = AG.x(v)-AG.width(v) /2;
if(AG.x(v)+AG.width (v)/2 > maxX) maxX = AG.x(v)+AG.width(v) /2;
if(AG.y(v)-AG.height(v)/2 < minY) minY = AG.y(v)-AG.height(v)/2;
if(AG.y(v)+AG.height(v)/2 > maxY) maxY = AG.y(v)+AG.height(v)/2;
}
minX -= m_minDistCC;
minY -= m_minDistCC;
for(node vCopy : GC.nodes) {
node v = GC.original(vCopy);
AG.x(v) -= minX;
AG.y(v) -= minY;
}
//.........这里部分代码省略.........