Ejemplo n.º 1
0
	face SimpleEmbedder::findBestExternalFace(
		const PlanRep& PG,
		const CombinatorialEmbedding& E)
	{
		FaceArray<int> weight(E);

		for(face f : E.faces)
			weight[f] = f->size();

		for(node v : PG.nodes)
		{
			if(PG.typeOf(v) != Graph::generalizationMerger)
				continue;

			adjEntry adjFound = nullptr;
			for(adjEntry adj : v->adjEdges) {
				if (adj->theEdge()->source() == v) {
					adjFound = adj;
					break;
				}
			}

			OGDF_ASSERT(adjFound->theEdge()->source() == v);

			node w = adjFound->theEdge()->target();
			bool isBase = true;

			for(adjEntry adj : w->adjEdges) {
				edge e = adj->theEdge();
				if(e->target() != w && PG.typeOf(e) == Graph::generalization) {
					isBase = false;
					break;
				}
			}

			if(isBase == false)
				continue;

			face f1 = E.leftFace(adjFound);
			face f2 = E.rightFace(adjFound);

			weight[f1] += v->indeg();
			if(f2 != f1)
				weight[f2] += v->indeg();
		}

		face fBest = E.firstFace();
		for(face f : E.faces)
			if(weight[f] > weight[fBest])
				fBest = f;

		return fBest;
	}
Ejemplo n.º 2
0
void CPlanarEdgeInserter::constructDualGraph(ClusterPlanRep& CPR,
											 CombinatorialEmbedding& E,
											 EdgeArray<edge>& arcRightToLeft,
											 EdgeArray<edge>& arcLeftToRight,
		 									 FaceArray<node>& nodeOfFace,
											 //NodeArray<face>&, faceOfNode,
											 EdgeArray<edge>& arcTwin)
{
	//dual graph gets two arcs for each edge (in both directions)
	//these arcs get their status (usable for path) depending on
	//the edge to be reinserted

	m_dualGraph.clear();
	//faceOfNode.init(m_dualGraph, 0);

	//*********************************
	//construct nodes
	//corresponding to the graphs faces
	face f;
	for (f = E.firstFace(); f; f = f->succ())
	{
		node v = m_dualGraph.newNode();
		nodeOfFace[f] = v;
		//faceOfNode[v] = f;
	}

	//*********************************
	//
	edge e;
	forall_edges(e, CPR)
	{
		edge arc1 = m_dualGraph.newEdge( nodeOfFace[E.rightFace(e->adjTarget())],
			nodeOfFace[E.rightFace(e->adjSource())] );
		arcLeftToRight[e] = arc1;
		edge arc2 = m_dualGraph.newEdge( nodeOfFace[E.rightFace(e->adjSource())],
			nodeOfFace[E.rightFace(e->adjTarget())] );
		arcRightToLeft[e] = arc2;
		arcTwin[arc1] = arc2;
		arcTwin[arc2] = arc1;
		m_arcOrig[arc1] = e->adjSource();//e->adjTarget();
		m_arcOrig[arc2] = e->adjTarget();//e->adjSource();
	}