Exemplo n.º 1
0
// Replaces the pertinent subtree by a P-node with leaves as children
// corresponding to the incoming edges of the node v. These edges
// are to be specified by their keys stored in leafKeys.
void PlanarPQTree::ReplaceRoot(SListPure<PlanarLeafKey<indInfo*>*> &leafKeys)
{
   if (m_pertinentRoot->status() == FULL)
      ReplaceFullRoot(leafKeys);
   else
      ReplacePartialRoot(leafKeys);
}
Exemplo n.º 2
0
// Function ReplacePartialRoot replaces all full nodes by a single P-node 
// with leaves corresponding the keys stored in leafKeys.
void PlanarPQTree::ReplacePartialRoot(SListPure<PlanarLeafKey<indInfo*>*> &leafKeys)
{
   m_pertinentRoot->childCount(m_pertinentRoot->childCount() + 1 -
							   fullChildren(m_pertinentRoot)->size());

   while (fullChildren(m_pertinentRoot)->size() > 1)
      removeChildFromSiblings(fullChildren(m_pertinentRoot)->popFrontRet());

   PQNode<edge,indInfo*,bool> *currentNode = fullChildren(m_pertinentRoot)->popFrontRet();

   currentNode->parent(m_pertinentRoot);
   m_pertinentRoot = currentNode;
   ReplaceFullRoot(leafKeys);
}
Exemplo n.º 3
0
void EmbedPQTree::ReplaceRoot(
	SListPure<PlanarLeafKey<indInfo*>*> &leafKeys,
	SListPure<edge> &frontier,
	SListPure<node> &opposed,
	SListPure<node> &nonOpposed,
	node v)
{
	SListPure<PQBasicKey<edge,indInfo*,bool>*> nodeFrontier;

	if (leafKeys.empty() && m_pertinentRoot == m_root)
	{
		front(m_pertinentRoot,nodeFrontier);
		m_pertinentRoot = 0;  // check for this emptyAllPertinentNodes

	} else {
		if (m_pertinentRoot->status() == FULL)
			ReplaceFullRoot(leafKeys,nodeFrontier,v);
		else
			ReplacePartialRoot(leafKeys,nodeFrontier,v);
	}

	// Check the frontier and get the direction indicators.
	while (!nodeFrontier.empty())
	{
		PQBasicKey<edge,indInfo*,bool>* entry = nodeFrontier.popFrontRet();
		if (entry->userStructKey()) // is a regular leaf
			frontier.pushBack(entry->userStructKey());

		else if (entry->userStructInfo()) {
			if (entry->userStructInfo()->changeDir)
				opposed.pushBack(entry->userStructInfo()->v);
			else
				nonOpposed.pushBack(entry->userStructInfo()->v);
		}
	}
}
Exemplo n.º 4
0
void EmbedPQTree::ReplacePartialRoot(
	SListPure<PlanarLeafKey<indInfo*>*> &leafKeys,
	SListPure<PQBasicKey<edge,indInfo*,bool>*> &frontier,
	node v)
{
	m_pertinentRoot->childCount(m_pertinentRoot->childCount() + 1 -
								fullChildren(m_pertinentRoot)->size());

	PQNode<edge,indInfo*,bool> *predNode = 0; // dummy
	PQNode<edge,indInfo*,bool> *beginSequence = 0; // marks begin consecuitve seqeunce
	PQNode<edge,indInfo*,bool> *endSequence	= 0; // marks end consecutive sequence
	PQNode<edge,indInfo*,bool> *beginInd = 0; // initially, marks direct sibling indicator
											  // next to beginSequence not contained 
											  // in consectuive sequence

	// Get beginning and end of sequence.
	while (fullChildren(m_pertinentRoot)->size())
	{
		PQNode<edge,indInfo*,bool> *currentNode = fullChildren(m_pertinentRoot)->popFrontRet();
		if (!clientSibLeft(currentNode) ||
			clientSibLeft(currentNode)->status() == EMPTY)
		{
			if (!beginSequence)
			{
				beginSequence = currentNode;
				predNode = clientSibLeft(currentNode);
				beginInd =PQTree<edge,indInfo*,bool>::clientSibLeft(currentNode);
			}
			else 
				endSequence = currentNode;
		}
		else if (!clientSibRight(currentNode) ||
				 clientSibRight(currentNode)->status() == EMPTY )
		{
			if (!beginSequence)
			{
				beginSequence = currentNode;
				predNode = clientSibRight(currentNode);
				beginInd =PQTree<edge,indInfo*,bool>::clientSibRight(currentNode);
			}
			else 
				endSequence = currentNode;
		}
	}

	SListPure<PQBasicKey<edge,indInfo*,bool>*> partialFrontier;
	

	// Now scan the sequence of full nodes. Remove all of them but the last.
	// Call ReplaceFullRoot on the last one.
	// For every full node get its frontier. Scan intermediate indicators.

	PQNode<edge,indInfo*,bool> *currentNode = beginSequence;
	while (currentNode != endSequence)
	{		
		PQNode<edge,indInfo*,bool>* nextNode = 
			clientNextSib(currentNode,predNode);
		front(currentNode,partialFrontier);
		frontier.conc(partialFrontier);

		PQNode<edge,indInfo*,bool>* currentInd	= PQTree<edge,indInfo*,bool>::
			clientNextSib(currentNode,beginInd);

		// Scan for intermediate direction indicators.
		while (currentInd != nextNode)
		{
			PQNode<edge,indInfo*,bool> *nextInd = PQTree<edge,indInfo*,bool>::
				clientNextSib(currentInd,currentNode);
			if (currentNode == currentInd->getSib(RIGHT)) //Direction changed
				currentInd->getNodeInfo()->userStructInfo()->changeDir = true;
			frontier.pushBack((PQBasicKey<edge,indInfo*,bool>*) 
								currentInd->getNodeInfo());
			removeChildFromSiblings(currentInd);
			m_pertinentNodes->pushBack(currentInd);
			currentInd = nextInd;
		}

		removeChildFromSiblings(currentNode);
		currentNode = nextNode;
	}
		
	currentNode->parent(m_pertinentRoot);
	m_pertinentRoot = currentNode;
	ReplaceFullRoot(leafKeys,partialFrontier,v,true,beginInd);
	frontier.conc(partialFrontier);
}