// takes a dfs stack and a transaction that is visited twice, and returns the corresponding cycle
// last access in the dfs stack belongs to tx
// the first and last access in the cycle belong to tx
Cycle* AspEventHandler::extract_cycle(DFSStack& stack, Transaction* tx) {
	num_cycles_++; // all cycles

	// if we have seen another cycle with tx as the revisited transaction, skip reporting this cycle
	if(txset_in_cycle.find(tx) != txset_in_cycle.end()) {
		return NULL;
	}
	// record this transaction, so we do not report cycles with the same revisited transaction
	txset_in_cycle.insert(tx);

	//----------------------------
	Cycle* cycle = new Cycle();
	num_unique_cycles_++; // unique cycles

	DFSStack::iterator itr = stack.begin();
	for(; itr < stack.end(); ++itr) {
		DFSStackElement current_elt = (*itr);
		if(current_elt.tx_ == tx) {
			break;
		}
	}

	for(; itr < stack.end(); ++itr) {
		DFSStackElement current_elt = (*itr);
		Edge edge = *(current_elt.begin_);
		cycle->push_back(edge.first);
		cycle->push_back(edge.second);
	}

	assert(cycle->front()->tx() == tx);
	assert(cycle->back()->tx() == tx);

	return cycle;
}
Beispiel #2
0
typename SimplexWithVertices<V>::Cycle	
SimplexWithVertices<V>::
boundary() const
{
	Cycle bdry;
	if (dimension() == 0)	return bdry;

	for (typename VertexContainer::const_iterator cur = vertices_.begin(); cur != vertices_.end(); ++cur)
	{
		bdry.push_back(*this);
		Self& s = bdry.back();
		s.vertices_.erase(*cur);
	}

	return bdry;
}