Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryRekun committed Dec 27, 2023
1 parent 1802311 commit 58d28aa
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions trunk/ii02415/task_03/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MyGraph {
destArounds.erase(remove(destArounds.begin(), destArounds.end(), src), destArounds.end());
}

void vizual() {
void const vizual() {
ofstream file("graph.dot");
if (!file) {
cout << "Ошибка при открытии файла." << endl;
Expand All @@ -58,7 +58,7 @@ class MyGraph {
cout << "Граф визуализирован в файле graph.png" << endl;
}

bool isEulerian() {
bool const isEulerian() {
for (const auto& top : tops) {
if (top.around.size() % 2 != 0) {
return false;
Expand All @@ -75,9 +75,9 @@ class MyGraph {
vector<bool> visited(tops.size(), false);
for (int i = 0; i < cycle.size() - 1; ++i) {
int src = cycle[i];
int dest = cycle[i + 1];
// int dest = cycle[i + 1];

if (find(tops[src].around.begin(), tops[src].around.end(), dest) == tops[src].around.end()) {
if (find(tops[src].around.begin(), tops[src].around.end(),int dest = cycle[i+1]) == tops[src].around.end()) {
return false;
}

Expand Down Expand Up @@ -139,10 +139,9 @@ class MyGraph {
}

for (int around : tops[currentTops].around) {
if (!visited[around]) {
if (findHamiltonianCycleRecursive(around, cycle, visited)) {
if (!visited[around] || findHamiltonianCycleRecursive(around, cycle, visited)) {
return true;
}

}
}

Expand Down Expand Up @@ -201,8 +200,8 @@ int main() {
Mygraph.vizual();

// Поиск Эйлерова цикла
vector<int> eulerianCycle = Mygraph.findEulerianCycle();
if (!eulerianCycle.empty()) {

if (vector<int> eulerianCycle = Mygraph.findEulerianCycle(); || !eulerianCycle.empty()) {
cout << "Эйлеров цикл: ";
for (int vertex : eulerianCycle) {
cout << vertex << " ";
Expand All @@ -214,8 +213,8 @@ int main() {
}

// Поиск Гамильтонова цикла
vector<int> hamiltonianCycle = Mygraph.findHamiltonianCycle();
if (!hamiltonianCycle.empty()) {

if (vector<int> hamiltonianCycle = Mygraph.findHamiltonianCycle(); || !hamiltonianCycle.empty()) {
cout << "Гамильтонов цикл: ";
for (int vertex : hamiltonianCycle) {
cout << vertex << " ";
Expand Down

0 comments on commit 58d28aa

Please sign in to comment.