-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhamiltonianwidget.cpp
More file actions
42 lines (38 loc) · 1.03 KB
/
hamiltonianwidget.cpp
File metadata and controls
42 lines (38 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "hamiltonianwidget.h"
#include "ui_hamiltonianwidget.h"
HamiltonianWidget::HamiltonianWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::HamiltonianWidget),cycleExist(false)
{
ui->setupUi(this);
}
HamiltonianWidget::~HamiltonianWidget()
{
delete ui;
}
void HamiltonianWidget::on_search_clicked()
{
Graph * myGraph=Engine::getInstance()->getGraph();
std::vector<int> cycle=HamiltonianCycle::hamiltonianCycle(myGraph);
if(cycle.size()>1){
QString result="Przykładowy cykl: ";
for(int index=0;index<cycle.size();index++){
result=result+" "+QString::number(cycle[index]+1);
}
ui->feedbackLabel->setText(result);
cycleExist=true;
cycle.push_back(cycle[0]);
myCycle=cycle;
}
else{
ui->feedbackLabel->setText(QString("Nie wykryto cyklu."));
cycleExist=false;
}
}
void HamiltonianWidget::on_drawOnCanvas_clicked()
{
on_search_clicked();
if(cycleExist){
Engine::getInstance()->setPath(myCycle);
}
}