Example #1
0
void profundidade(int i)
{
	/* Vetor de flags */
	int n;
	int flag[V+1];
	for ( n = 0; n <= V; ++n) flag[n] = 0;

	/* Início do Procedimento */
	flag[i] = 1;
	int adj;
	for ( adj = 1; adj <= V; adj++ )
	{
		if ( grafo[i][adj] == 1 && flag[adj] == 0 )
		{
			printf("%d ", adj);
			profundidade( adj );
		}
	}
	printf("\n");
	flag[i] = 2;
}
Example #2
0
void Principal::start() {
    vector<vector<int> > start(3);
    vector <vector<int> > goal(3);

    ui->text_log->setText("");

    start.at(0).push_back(3);
    start.at(0).push_back(1);
    start.at(0).push_back(2);
    start.at(1).push_back(4);
    start.at(1).push_back(5);
    start.at(1).push_back(8);
    start.at(2).push_back(6);
    start.at(2).push_back(0);
    start.at(2).push_back(7);

    goal.at(0).push_back(0);
    goal.at(0).push_back(1);
    goal.at(0).push_back(2);
    goal.at(1).push_back(3);
    goal.at(1).push_back(4);
    goal.at(1).push_back(5);
    goal.at(2).push_back(6);
    goal.at(2).push_back(7);
    goal.at(2).push_back(8);

    this->setLog("Inversões: "+QString("%1").arg(inversoes(start)));
    this->setLog("Algortimo: "+ui->combo_box->currentText());
    QString a = ui->combo_box->currentText();
    QString b = "Largura";

    if(a == b){
        largura(start, goal);
    } else {
        profundidade(start, goal);
    }

    qApp->processEvents();
}