本文整理汇总了C++中MultilevelGraph::x方法的典型用法代码示例。如果您正苦于以下问题:C++ MultilevelGraph::x方法的具体用法?C++ MultilevelGraph::x怎么用?C++ MultilevelGraph::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultilevelGraph
的用法示例。
在下文中一共展示了MultilevelGraph::x方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: placeOneLevel
void RandomPlacer::placeOneLevel(MultilevelGraph &MLG)
{
int level = MLG.getLevel();
DPoint center(0.0, 0.0);
double radius = 0.0;
Graph &G = MLG.getGraph();
double n = G.numberOfNodes();
if (n > 0) {
for(node v : G.nodes) {
center = center + DPoint( MLG.x(v), MLG.y(v) );
}
center = DPoint(center.m_x / n, center.m_y / n);
for(node v : G.nodes) {
double r = sqrt( MLG.x(v) * MLG.x(v) + MLG.y(v) * MLG.y(v) );
if (r > radius) radius = r;
}
radius *= m_circleSizeFactor;
} else {
radius = 10.0 * m_circleSizeFactor;
}
while (MLG.getLevel() == level && MLG.getLastMerge() != nullptr)
{
placeOneNode(MLG, center, radius);
}
}
示例2: placeOneNode
void BarycenterPlacer::placeOneNode(MultilevelGraph &MLG)
{
node merged = MLG.undoLastMerge();
double x = 0.0;
double y = 0.0;
double i = 0.0;
for(adjEntry adj : merged->adjEdges) {
if(m_weightedPositions) {
double weight = 1.0 / MLG.weight(adj->theEdge());
i = i + weight;
x += MLG.x(adj->twinNode()) * weight;
y += MLG.y(adj->twinNode()) * weight;
} else {
i = i + 1.f;
x += MLG.x(adj->twinNode());
y += MLG.y(adj->twinNode());
}
}
OGDF_ASSERT(i > 0);
x = x / i;
y = y / i;
MLG.x(merged, x + ((m_randomOffset)?(float)randomDouble(-1.0, 1.0):0.f));
MLG.y(merged, y + ((m_randomOffset)?(float)randomDouble(-1.0, 1.0):0.f));
}
示例3: placeOneNode
void SolarPlacer::placeOneNode(MultilevelGraph &MLG)
{
NodeMerge * lastNM = MLG.getLastMerge();
float x = 0.0;
float y = 0.0;
int i = 0;
node sun = MLG.getNode(lastNM->m_changedNodes.front());
std::vector< std::pair<int, float> > positions = lastNM->m_position;
node merged = MLG.undoLastMerge();
if (positions.size() > 0) {
for (std::vector< std::pair<int, float> >::iterator j = positions.begin(); j != positions.end(); j++) {
float factor = (*j).second;
node other_sun = MLG.getNode((*j).first);
i++;
x += MLG.x(sun) * factor + MLG.x(other_sun) * (1.0f-factor);
y += MLG.y(sun) * factor + MLG.y(other_sun) * (1.0f-factor);
}
} else {
i++;
x += MLG.x(sun);
y += MLG.y(sun);
}
OGDF_ASSERT(i > 0);
if (positions.size() == 0 || m_randomOffset) {
x += (float)randomDouble(-1.0, 1.0);
y += (float)randomDouble(-1.0, 1.0);
}
MLG.x(merged, (x / static_cast<float>(i)));
MLG.y(merged, (y / static_cast<float>(i)));
}
示例4: placeOneNode
void SolarPlacer::placeOneNode(MultilevelGraph &MLG)
{
NodeMerge * lastNM = MLG.getLastMerge();
double x = 0.0;
double y = 0.0;
int i = 0;
node sun = MLG.getNode(lastNM->m_changedNodes.front());
std::vector< std::pair<int, double> > positions = lastNM->m_position;
node merged = MLG.undoLastMerge();
if (positions.size() > 0) {
for (const std::pair<int, double> &p : positions) {
double factor = p.second;
node other_sun = MLG.getNode(p.first);
i++;
x += MLG.x(sun) * factor + MLG.x(other_sun) * (1.0f-factor);
y += MLG.y(sun) * factor + MLG.y(other_sun) * (1.0f-factor);
}
} else {
i++;
x += MLG.x(sun);
y += MLG.y(sun);
}
OGDF_ASSERT(i > 0);
if (positions.size() == 0 || m_randomOffset) {
x += randomDouble(-1.0, 1.0);
y += randomDouble(-1.0, 1.0);
}
MLG.x(merged, (x / static_cast<double>(i)));
MLG.y(merged, (y / static_cast<double>(i)));
}
示例5: placeOneNode
void RandomPlacer::placeOneNode(MultilevelGraph &MLG, DPoint center, double radius)
{
node merged = MLG.undoLastMerge();
float angle = (float)randomDouble(0.0, 2 * Math::pi);
float randRadius = float(sqrt(randomDouble(0.0, radius * radius)));
MLG.x(merged, cos(angle) * randRadius + ((m_randomOffset)?(float)randomDouble(-1.0, 1.0):0.f));
MLG.y(merged, sin(angle) * randRadius + ((m_randomOffset)?(float)randomDouble(-1.0, 1.0):0.f));
}
示例6: placeOneNode
void MedianPlacer::placeOneNode(MultilevelGraph &MLG)
{
node merged = MLG.undoLastMerge();
int i = 0;
std::vector<double> xVector;
std::vector<double> yVector;
adjEntry adj;
forall_adj(adj, merged) {
i++;
xVector.push_back(MLG.x(adj->twinNode()));
yVector.push_back(MLG.y(adj->twinNode()));
}
示例7: placeOneLevel
void RandomPlacer::placeOneLevel(MultilevelGraph &MLG)
{
int level = MLG.getLevel();
DPoint center(0.0, 0.0);
double radius = 0.0;
Graph &G = MLG.getGraph();
double n = G.numberOfNodes();
if (n > 0) {
node v;
forall_nodes(v, G) {
center = center + DPoint( MLG.x(v), MLG.y(v) );
}
示例8: placeOneLevel
void CirclePlacer::placeOneLevel(MultilevelGraph &MLG)
{
int level = MLG.getLevel();
DPoint center(0.0, 0.0);
float radius = 0.0;
std::map<node, bool> oldNodes;
Graph &G = MLG.getGraph();
double n = G.numberOfNodes();
if (n > 0) {
node v;
forall_nodes(v, G) {
oldNodes[v] = true;
center = center + DPoint( MLG.x(v), MLG.y(v) );
}
示例9: copyNodeTo
void MultilevelGraph::copyNodeTo(node v, MultilevelGraph &MLG, std::map<node, node> &tempNodeAssociations, bool associate, int index)
{
node v_new;
if (index == -1) {
v_new = MLG.m_G->newNode();
} else {
v_new = MLG.m_G->newNode(index);
}
tempNodeAssociations[v] = v_new;
if(associate) {
MLG.m_nodeAssociations[v_new] = v->index();
}
MLG.m_radius[v_new] = m_radius[v];
MLG.x(v_new, x(v));
MLG.y(v_new, y(v));
}