当前位置: 首页>>代码示例>>C++>>正文


C++ MultilevelGraph类代码示例

本文整理汇总了C++中MultilevelGraph的典型用法代码示例。如果您正苦于以下问题:C++ MultilevelGraph类的具体用法?C++ MultilevelGraph怎么用?C++ MultilevelGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MultilevelGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
	}
}
开发者ID:marvin2k,项目名称:ogdf,代码行数:27,代码来源:RandomPlacer.cpp

示例2: 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));
}
开发者ID:marvin2k,项目名称:ogdf,代码行数:8,代码来源:RandomPlacer.cpp

示例3: placeOneLevel

void BarycenterPlacer::placeOneLevel(MultilevelGraph &MLG)
{
	int level = MLG.getLevel();
	while (MLG.getLevel() == level && MLG.getLastMerge() != nullptr)
	{
		placeOneNode(MLG);
	}
}
开发者ID:lncosie,项目名称:ogdf,代码行数:8,代码来源:BarycenterPlacer.cpp

示例4: 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()));
	}
开发者ID:Alihina,项目名称:ogdf,代码行数:12,代码来源:MedianPlacer.cpp

示例5: 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) );
		}
开发者ID:kdbanman,项目名称:browseRDF,代码行数:13,代码来源:RandomPlacer.cpp

示例6: reInsertGraph

void MultilevelGraph::reInsertGraph(MultilevelGraph &MLG)
{
	std::map<node, node> tempNodeAssociations;

	for(node v : MLG.m_G->nodes) {
		MLG.copyNodeTo(v, *this, tempNodeAssociations, false, MLG.m_nodeAssociations[v]);
	}

	for(edge e : MLG.m_G->edges) {
		MLG.copyEdgeTo(e, *this, tempNodeAssociations, false, MLG.m_edgeAssociations[e]);
	}

	initReverseIndizes();
}
开发者ID:ogdf,项目名称:ogdf,代码行数:14,代码来源:MultilevelGraph.cpp

示例7: 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));
}
开发者ID:lncosie,项目名称:ogdf,代码行数:26,代码来源:BarycenterPlacer.cpp

示例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) );
		}
开发者ID:SiteView,项目名称:NNMQT,代码行数:15,代码来源:CirclePlacer.cpp

示例9: buildAllLevels

void IndependentSetMerger::buildAllLevels(MultilevelGraph &MLG)
{
	m_numLevels = 1;
	MLG.updateReverseIndizes();

	std::vector< std::vector<node> > levelNodes;
	Graph &G = MLG.getGraph();

	// calc MIS
	NodeArray<bool> nodeMarks(G, false);
	std::vector<node> IScandidates;
	node v;
	forall_nodes(v, G) {
		IScandidates.push_back(v);
	}
开发者ID:mneumann,项目名称:tulip,代码行数:15,代码来源:IndependentSetMerger.cpp

示例10: call

void ModularMultilevelMixer::call(MultilevelGraph &MLG)
{
	const Graph &G = MLG.getGraph();

	m_errorCode = ercNone;
	clock_t time = clock();
	if ((m_multilevelBuilder.valid() == false || m_initialPlacement.valid() == false) && m_oneLevelLayoutModule.valid() == false) {
		OGDF_THROW(AlgorithmFailureException);
	}

	if (m_fixedEdgeLength > 0.0) {
		edge e;
		forall_edges(e,G) {
			MLG.weight(e, m_fixedEdgeLength);
		}
开发者ID:mneumann,项目名称:tulip,代码行数:15,代码来源:ModularMultilevelMixer.cpp

示例11: 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));
}
开发者ID:ogdf,项目名称:ogdf,代码行数:17,代码来源:MultilevelGraph.cpp

示例12: buildOneLevel

bool RandomMerger::buildOneLevel(MultilevelGraph &MLG)
{
	Graph &G = MLG.getGraph();
	int level = MLG.getLevel() + 1;
	int numNodes = G.numberOfNodes();

	if (numNodes <= 3) {
		return false;
	}

	node v;
	int index = 0;
	Array<node> candidates(numNodes);
	forall_nodes(v, G) {
		candidates[index] = v;
		index++;
	}
开发者ID:SiteView,项目名称:NNMQT,代码行数:17,代码来源:RandomMerger.cpp

示例13: MultilevelGraph

MultilevelGraph * MultilevelGraph::removeOneCC(std::vector<node> &componentSubArray)
{
	MultilevelGraph * MLGcomponent = new MultilevelGraph();
	std::map<node, node> tempNodeAssociations;

	// copy nodes
	for (node v : componentSubArray) {
		copyNodeTo(v, *MLGcomponent, tempNodeAssociations, true);
	}

	// move edges
	for (node v : componentSubArray) {
#if 0
		std::vector<edge> toDelete;
#endif
		for(adjEntry adj : v->adjEntries) {
			edge e = adj->theEdge();
			if (e->source() == v) {
				copyEdgeTo(e, *MLGcomponent, tempNodeAssociations, true);
#if 0
				toDelete.push_back(e);
#endif
			}
		}
#if 0
		// Test if this is good for Performace.
		// makes Assert Edges == 0 fail!
		// Because of self loops!
		for(std::vector<edge>::iterator j = toDelete.begin(); j != toDelete.end(); j++) {
			m_G->delEdge(*j);
		}
#endif
	}

	tempNodeAssociations.clear();

	// delete nodes
	for (node v : componentSubArray) {
		m_G->delNode(v);
	}

	MLGcomponent->initReverseIndizes();
	return MLGcomponent;
}
开发者ID:ogdf,项目名称:ogdf,代码行数:44,代码来源:MultilevelGraph.cpp

示例14:

std::vector<node> SolarMerger::selectSuns(MultilevelGraph &MLG)
{
	Graph &G = MLG.getGraph();
	std::vector<node> suns;
	std::vector<node> candidates;

	node v;
	forall_nodes(v, G) {
		candidates.push_back(v);
	}
开发者ID:SiteView,项目名称:NNMQT,代码行数:10,代码来源:SolarMerger.cpp

示例15: buildOneLevel

bool RandomMerger::buildOneLevel(MultilevelGraph &MLG)
{
	Graph &G = MLG.getGraph();
	int level = MLG.getLevel() + 1;
	int numNodes = G.numberOfNodes();

	if (numNodes <= 3) {
		return false;
	}

	int index = 0;
	Array<node> candidates(numNodes);
	for(node v : G.nodes) {
		candidates[index] = v;
		index++;
	}

	int candSize = candidates.size();
	while (candSize > numNodes / m_levelSizeFactor)
	{
		index = randomNumber(0, candSize-1);
		node mergeNode = candidates[index];
		candidates[index] = candidates[candSize-1];
		candSize--;
		node parent = nullptr;

		if (mergeNode->degree() > 0) {
			int index = randomNumber(0, mergeNode->degree()-1);
			int i = 0;
			for(adjEntry adj : mergeNode->adjEntries) {
				if (i == index) {
					parent = adj->twinNode();
					break;
				} else {
					i++;
				}
			}
		} else {
			do {
				index = randomNumber(0, candSize-1);
				parent = candidates[index];
			} while (parent == mergeNode);
			candidates[index] = candidates[candSize-1];
			candSize--;
		}

		NodeMerge * NM = new NodeMerge(level);
		bool ret = MLG.changeNode(NM, parent, MLG.radius(parent), mergeNode);
		OGDF_ASSERT( ret );
		MLG.moveEdgesToParent(NM, mergeNode, parent, true, m_adjustEdgeLengths);
		ret = MLG.postMerge(NM, mergeNode);
		if( !ret ) {
			delete NM;
		}
	}

	return true;
}
开发者ID:marvin2k,项目名称:ogdf,代码行数:58,代码来源:RandomMerger.cpp


注:本文中的MultilevelGraph类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。