Пример #1
0
int countCycle(const Matrix &mat, Cycle cycle)
{
    Cycle::const_iterator it;
    int cycle_mat = 0;
    for (it = cycle.begin(); it != cycle.end(); ++it)
    {
        if (it != cycle.begin())
            cycle_mat += mat[*it][*prev(it)];
    }

    return cycle_mat;
}
Пример #2
0
void displayCycle(const Matrix &mat, Cycle cycle)
{
    Cycle::const_iterator it;

    for (it = cycle.begin(); it != cycle.end(); ++it)
        cout << *it + 1 << endl;
}
// TODO(elmas): report more information about the cycle
void AspEventHandler::report_cycles(CyclePtrList cycles) {
	int i = 1;
	fprintf(report_file_, "Number of unique cycles: %d\n\n", cycles.size());
	for(CyclePtrList::iterator itr = cycles_.begin(); itr < cycles_.end(); itr = cycles_.erase(itr)) {
		Cycle* cycle = (*itr);

		// report cycle
		fprintf(report_file_, "Cycle no: %d\n", i);
		for(Cycle::iterator iter = cycle->begin(); iter < cycle->end(); ++iter) {
			AccessBase* access = (*iter);
			fprintf(report_file_, "%s\n", access->ToString().c_str());
		}
		fprintf(report_file_, "\n");

		delete cycle;

		++i;
	}
}