Exemplo n.º 1
0
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);
	}
}
Exemplo n.º 2
0
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)));
}
Exemplo n.º 3
0
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)));
}
Exemplo n.º 4
0
void BarycenterPlacer::placeOneLevel(MultilevelGraph &MLG)
{
	int level = MLG.getLevel();
	while (MLG.getLevel() == level && MLG.getLastMerge() != nullptr)
	{
		placeOneNode(MLG);
	}
}
Exemplo n.º 5
0
void ZeroPlacer::placeOneNode(MultilevelGraph &MLG)
{
	NodeMerge * NM = MLG.getLastMerge();
	node parent = MLG.getNode(NM->m_changedNodes[0]);
	node merged = MLG.undoLastMerge();
	MLG.x(merged, MLG.x(parent) + ((m_randomOffset)?(float)randomDouble(-m_randomRange, m_randomRange):0.f));
	MLG.y(merged, MLG.y(parent) + ((m_randomOffset)?(float)randomDouble(-m_randomRange, m_randomRange):0.f));
}
Exemplo n.º 6
0
void ZeroPlacer::placeOneLevel(MultilevelGraph &MLG)
{
	int level = MLG.getLevel();
	while (MLG.getLevel() == level && MLG.getLastMerge() != 0)
	{
		placeOneNode(MLG);
	}
}