Пример #1
0
	//---------------------------------------------------------
	// construct dual graph, marks dual edges corresponding to generalization
	// in m_primalIsGen
	// assumes that m_pDual, m_primalAdj and m_nodeOf are already constructed
	//
	void FixEdgeInserterUMLCore::constructDual(const CombinatorialEmbedding &E)
	{
		// insert a node in the dual graph for each face in E
		for(face f : E.faces)
			m_nodeOf[f] = m_dual.newNode();


		// Insert an edge into the dual graph for each adjacency entry in E.
		// The edges are directed from the left face to the right face.
		for(node v : m_pr.nodes)
		{
			for(adjEntry adj : v->adjEdges)
			{
				node vLeft  = m_nodeOf[E.leftFace (adj)];
				node vRight = m_nodeOf[E.rightFace(adj)];

				edge e = m_dual.newEdge(vLeft,vRight);
				m_primalAdj[e] = adj;

				// mark dual edges corresponding to generalizations
				if (m_pr.typeOf(adj->theEdge()) == Graph::generalization)
					m_primalIsGen[e] = true;
			}
		}

		// Augment the dual graph by two new vertices. These are used temporarily
		// when searching for a shortest path in the dual graph.
		m_vS = m_dual.newNode();
		m_vT = m_dual.newNode();
	}
Пример #2
0
	void FixEdgeInserterCore::removeEdge(CombinatorialEmbedding &E, edge eOrig)
	{
		const List<edge> &path = m_pr.chain(eOrig);
		for(edge e : path)
		{
			adjEntry adj = e->adjSource();
			m_delFaces->insert(E.leftFace  (adj));
			m_delFaces->insert(E.rightFace (adj));
		}

		// delete all corresponding nodes in dual
		for(face f : m_delFaces->faces())
			m_dual.delNode(m_nodeOf[f]);

		m_delFaces->clear();

		// remove edge path from PG
		m_pr.removeEdgePathEmbedded(E,eOrig,*m_newFaces);

		// update dual
		// insert new nodes
		for(face f : m_newFaces->faces()) {
			m_nodeOf[f] = m_dual.newNode();
		}

		// insert new edges into dual
		for(face f : m_newFaces->faces())
			insertEdgesIntoDualAfterRemove(E, f);

		m_newFaces->clear();
	}
Пример #3
0
	//---------------------------------------------------------
	// construct dual graph
	// assumes that m_pDual, m_primalAdj and m_nodeOf are already constructed
	//
	void FixEdgeInserterCore::constructDual(const CombinatorialEmbedding &E)
	{
		// insert a node in the dual graph for each face in E
		for(face f : E.faces)
			m_nodeOf[f] = m_dual.newNode();


		// Insert an edge into the dual graph for each adjacency entry in E.
		// The edges are directed from the left face to the right face.
		for(node v : m_pr.nodes)
		{
			for(adjEntry adj : v->adjEdges)
			{
				// Do not insert edges into dual if crossing the original edge
				// is forbidden
				if(m_pForbidden && (*m_pForbidden)[m_pr.original(adj->theEdge())] == true)
					continue;

				node vLeft  = m_nodeOf[E.leftFace (adj)];
				node vRight = m_nodeOf[E.rightFace(adj)];

				m_primalAdj[m_dual.newEdge(vLeft,vRight)] = adj;
			}
		}

		// Augment the dual graph by two new vertices. These are used temporarily
		// when searching for a shortest path in the dual graph.
		m_vS = m_dual.newNode();
		m_vT = m_dual.newNode();
	}
Пример #4
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;
	}
Пример #5
0
	void FixEdgeInserterUMLCore::insertEdgesIntoDual(const CombinatorialEmbedding &E, adjEntry adjSrc)
	{
		face f = E.rightFace(adjSrc);
		node vRight = m_nodeOf[f];

		adjEntry adj1 = f->firstAdj(), adj = adj1;
		do {
			node vLeft = m_nodeOf[E.leftFace(adj)];

			edge eLR = m_dual.newEdge(vLeft,vRight);
			m_primalAdj[eLR] = adj;

			edge eRL = m_dual.newEdge(vRight,vLeft);
			m_primalAdj[eRL] = adj->twin();

			if(m_pr.typeOf(adj->theEdge()) == Graph::generalization)
				m_primalIsGen[eLR] = m_primalIsGen[eRL] = true;
		}
		while((adj = adj->faceCycleSucc()) != adj1);

		// the other face adjacent to *itEdge ...
		f = E.rightFace(adjSrc->twin());
		vRight = m_nodeOf[f];

		adj1 = f->firstAdj();
		adj = adj1;
		do {
			node vLeft = m_nodeOf[E.leftFace(adj)];

			edge eLR = m_dual.newEdge(vLeft,vRight);
			m_primalAdj[eLR] = adj;

			edge eRL = m_dual.newEdge(vRight,vLeft);
			m_primalAdj[eRL] = adj->twin();

			if(m_pr.typeOf(adj->theEdge()) == Graph::generalization)
				m_primalIsGen[eLR] = m_primalIsGen[eRL] = true;
		}
		while((adj = adj->faceCycleSucc()) != adj1);
	}
Пример #6
0
	void FixEdgeInserterCore::insertEdgesIntoDual(const CombinatorialEmbedding &E, adjEntry adjSrc)
	{
		face f = E.rightFace(adjSrc);
		node vRight = m_nodeOf[f];

		adjEntry adj1 = f->firstAdj(), adj = adj1;
		do {
			if(m_pForbidden && (*m_pForbidden)[m_pr.original(adj->theEdge())] == true)
				continue;

			node vLeft = m_nodeOf[E.leftFace(adj)];

			edge eLR = m_dual.newEdge(vLeft,vRight);
			m_primalAdj[eLR] = adj;

			edge eRL = m_dual.newEdge(vRight,vLeft);
			m_primalAdj[eRL] = adj->twin();
		}
		while((adj = adj->faceCycleSucc()) != adj1);

		// the other face adjacent to *itEdge ...
		f = E.rightFace(adjSrc->twin());
		vRight = m_nodeOf[f];

		adj1 = f->firstAdj();
		adj = adj1;
		do {
			if(m_pForbidden && (*m_pForbidden)[m_pr.original(adj->theEdge())] == true)
				continue;

			node vLeft = m_nodeOf[E.leftFace(adj)];

			edge eLR = m_dual.newEdge(vLeft,vRight);
			m_primalAdj[eLR] = adj;

			edge eRL = m_dual.newEdge(vRight,vLeft);
			m_primalAdj[eRL] = adj->twin();
		}
		while((adj = adj->faceCycleSucc()) != adj1);
	}
Пример #7
0
	face SimpleEmbedder::findBestExternalFace(const PlanRep& PG,
	                                          const CombinatorialEmbedding& E)
	{
		FaceArray<int> weight(E);

		face f;
		forall_faces(f,E)
			weight[f] = f->size();

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

			adjEntry adj;
			forall_adj(adj,v) {
				if(adj->theEdge()->source() == v)
					break;
			}

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

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

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

			if(isBase == false)
				continue;

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

			weight[f1] += v->indeg();
			if(f2 != f1)
				weight[f2] += v->indeg();
		}
Пример #8
0
	void FixEdgeInserterUMLCore::insertEdgesIntoDualAfterRemove(const CombinatorialEmbedding &E, face f)
	{
		node vRight = m_nodeOf[f];

		adjEntry adj1 = f->firstAdj(), adj = adj1;
		do {
			node vLeft = m_nodeOf[E.leftFace(adj)];

			edge eLR = m_dual.newEdge(vLeft,vRight);
			m_primalAdj[eLR] = adj;

			edge eRL = m_dual.newEdge(vRight,vLeft);
			m_primalAdj[eRL] = adj->twin();

			if(m_pr.typeOf(adj->theEdge()) == Graph::generalization)
			{
				m_primalIsGen[eLR] = m_primalIsGen[eRL] = true;
			}
		}
		while((adj = adj->faceCycleSucc()) != adj1);
	}
Пример #9
0
	void FixEdgeInserterCore::insertEdge(CombinatorialEmbedding &E, edge eOrig, const SList<adjEntry> &crossed)
	{
		// remove dual nodes on insertion path
		SListConstIterator<adjEntry> it;
		for(it = crossed.begin(); it != crossed.rbegin(); ++it) {
			m_dual.delNode(m_nodeOf[E.rightFace(*it)]);
		}

		// update primal
		m_pr.insertEdgePathEmbedded(eOrig,E,crossed);

		// insert new face nodes into dual
		const List<edge> &path = m_pr.chain(eOrig);
		for(edge e : path)
		{
			adjEntry adj = e->adjSource();
			m_nodeOf[E.leftFace (adj)] = m_dual.newNode();
			m_nodeOf[E.rightFace(adj)] = m_dual.newNode();
		}

		// insert new edges into dual
		for(edge e : path)
			insertEdgesIntoDual(E, e->adjSource());
	}