Лабораторная работа по Алгоритмам и структурам данных. Курсова работа по АиСД. Палунин Артем. Отчет по Курсовой работе по дисциплине Алгоритмы и структуры данных Тема Графы Студент гр. 9891 Палунин А. И. Преподаватель
Скачать 176.26 Kb.
|
goto exit; } //конец разбиения матрицы инцедентности основного графа //Сравниваем подматрицу инцедентности основного графа с подматрицей //и ищем изоморфный подграф заданному подграфу for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (massive_temp_3[i][j] == 1) { count_1++; } if (massive_temp_3[i][j] == 0) { count_0++; } if (massive_temp_3[i][j] == -1) { count_11++; } } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (massive_2[i][j] == 1) { count_1--; } if (massive_2[i][j] == 0) { count_0--; } if (massive_2[i][j] == -1) { count_11--; } } } if (count_1 == 0 && count_0 == 0 && count_11 == 0) { count_1 = 0; count_0 = 0; count_11 = 0; cout << "\nПодозрение на изоморфный граф! Начинаем перебор!\n"; for (int i = 0; i < number_node_temp_2; i++) { for (int j = 0; j < number_edge_temp_2; j++) { cout << "|"; cout << setfill('_'); cout << setw(3) << massive_temp_3[i][j]; } cout << setw(3) << "|N_" << i + 1 << "\n"; } if (massive_2[0][0] == massive_temp_3[0][0] && massive_2[0][1] == massive_temp_3[0][1] && massive_2[0][2] == massive_temp_3[0][2] && massive_2[1][0] == massive_temp_3[1][0] && massive_2[1][1] == massive_temp_3[1][1] && massive_2[1][2] == massive_temp_3[1][2] && massive_2[2][0] == massive_temp_3[2][0] && massive_2[2][1] == massive_temp_3[2][1] && massive_2[2][2] == massive_temp_3[2][2]) { cout << "Данный граф является изоморфным. Поиск завершен\n"; goto exit; } cout << "Строки ещё не менялись: \n"; cout <<"Перестановка № 1: \n"; swap(massive_temp_3[0][0], massive_temp_3[0][1]); swap(massive_temp_3[1][0], massive_temp_3[1][1]); swap(massive_temp_3[2][0], massive_temp_3[2][1]); for (int i = 0; i < number_node_temp_2; i++) { for (int j = 0; j < number_edge_temp_2; j++) { cout << "|"; cout << setfill('_'); cout << setw(3) << massive_temp_3[i][j]; } cout << setw(3) << "|N_" << i + 1 << "\n"; } if (massive_2[0][0] == massive_temp_3[0][0] && massive_2[0][1] == massive_temp_3[0][1] && massive_2[0][2] == massive_temp_3[0][2] && massive_2[1][0] == massive_temp_3[1][0] && massive_2[1][1] == massive_temp_3[1][1] && massive_2[1][2] == massive_temp_3[1][2] && massive_2[2][0] == massive_temp_3[2][0] && massive_2[2][1] == massive_temp_3[2][1] && massive_2[2][2] == massive_temp_3[2][2]) { cout << "Данный граф является изоморфным. Поиск завершен\n"; goto exit; } cout << "Перестановка № 2: \n"; swap(massive_temp_3[0][1], massive_temp_3[0][2]); swap(massive_temp_3[1][1], massive_temp_3[1][2]); swap(massive_temp_3[2][1], massive_temp_3[2][2]); for (int i = 0; i < number_node_temp_2; i++) { for (int j = 0; j < number_edge_temp_2; j++) { cout << "|"; cout << setfill('_'); cout << setw(3) << massive_temp_3[i][j]; } cout << setw(3) << "|N_" << i + 1 << "\n"; } if (massive_2[0][0] == massive_temp_3[0][0] && massive_2[0][1] == massive_temp_3[0][1] && massive_2[0][2] == massive_temp_3[0][2] && massive_2[1][0] == massive_temp_3[1][0] && massive_2[1][1] == massive_temp_3[1][1] && massive_2[1][2] == massive_temp_3[1][2] && massive_2[2][0] == massive_temp_3[2][0] && massive_2[2][1] == massive_temp_3[2][1] && massive_2[2][2] == massive_temp_3[2][2]) { cout << "Данный граф является изоморфным. Поиск завершен\n"; goto exit; } cout << "Перестановка № 3: \n"; swap(massive_temp_3[0][0], massive_temp_3[0][1]); swap(massive_temp_3[1][0], massive_temp_3[1][1]); swap(massive_temp_3[2][0], massive_temp_3[2][1]); for (int i = 0; i < number_node_temp_2; i++) { for (int j = 0; j < number_edge_temp_2; j++) { cout << "|"; cout << setfill('_'); cout << setw(3) << massive_temp_3[i][j]; } cout << setw(3) << "|N_" << i + 1 << "\n"; } if (massive_2[0][0] == massive_temp_3[0][0] && massive_2[0][1] == massive_temp_3[0][1] && massive_2[0][2] == massive_temp_3[0][2] && massive_2[1][0] == massive_temp_3[1][0] && massive_2[1][1] == massive_temp_3[1][1] && massive_2[1][2] == massive_temp_3[1][2] && massive_2[2][0] == massive_temp_3[2][0] && massive_2[2][1] == massive_temp_3[2][1] && massive_2[2][2] == massive_temp_3[2][2]) { cout << "Данный граф является изоморфным. Поиск завершен\n"; goto exit; } cout << "Перестановка № 4: \n"; swap(massive_temp_3[0][1], massive_temp_3[0][2]); swap(massive_temp_3[1][1], massive_temp_3[1][2]); swap(massive_temp_3[2][1], massive_temp_3[2][2]); for (int i = 0; i < number_node_temp_2; i++) { for (int j = 0; j < number_edge_temp_2; j++) { cout << "|"; cout << setfill('_'); cout << setw(3) << massive_temp_3[i][j]; } cout << setw(3) << "|N_" << i + 1 << "\n"; } if (massive_2[0][0] == massive_temp_3[0][0] && massive_2[0][1] == massive_temp_3[0][1] && massive_2[0][2] == massive_temp_3[0][2] && massive_2[1][0] == massive_temp_3[1][0] && massive_2[1][1] == massive_temp_3[1][1] && massive_2[1][2] == massive_temp_3[1][2] && massive_2[2][0] == massive_temp_3[2][0] && massive_2[2][1] == massive_temp_3[2][1] && massive_2[2][2] == massive_temp_3[2][2]) { cout << "Данный граф является изоморфным. Поиск завершен\n"; goto exit; } cout << "Перестановка № 5: \n"; swap(massive_temp_3[0][0], massive_temp_3[0][1]); swap(massive_temp_3[1][0], massive_temp_3[1][1]); swap(massive_temp_3[2][0], massive_temp_3[2][1]); for (int i = 0; i < number_node_temp_2; i++) { for (int j = 0; j < number_edge_temp_2; j++) { cout << "|"; cout << setfill('_'); cout << setw(3) << massive_temp_3[i][j]; } cout << setw(3) << "|N_" << i + 1 << "\n"; } if (massive_2[0][0] == massive_temp_3[0][0] && massive_2[0][1] == massive_temp_3[0][1] && massive_2[0][2] == massive_temp_3[0][2] && massive_2[1][0] == massive_temp_3[1][0] && massive_2[1][1] == massive_temp_3[1][1] && massive_2[1][2] == massive_temp_3[1][2] && massive_2[2][0] == massive_temp_3[2][0] && massive_2[2][1] == massive_temp_3[2][1] && massive_2[2][2] == massive_temp_3[2][2]) { cout << "Данный граф является изоморфным. Поиск завершен\n"; goto exit; } cout << "Перестановка № 6: \n"; swap(massive_temp_3[0][1], massive_temp_3[0][2]); swap(massive_temp_3[1][1], massive_temp_3[1][2]); swap(massive_temp_3[2][1], massive_temp_3[2][2]); for (int i = 0; i < number_node_temp_2; i++) { for (int j = 0; j < number_edge_temp_2; j++) { cout << "|"; cout << setfill('_'); cout << setw(3) << massive_temp_3[i][j]; } cout << setw(3) << "|N_" << i + 1 << "\n"; } if (massive_2[0][0] == massive_temp_3[0][0] && massive_2[0][1] == massive_temp_3[0][1] && massive_2[0][2] == massive_temp_3[0][2] && massive_2[1][0] == massive_temp_3[1][0] && massive_2[1][1] == massive_temp_3[1][1] && massive_2[1][2] == massive_temp_3[1][2] && massive_2[2][0] == massive_temp_3[2][0] && massive_2[2][1] == massive_temp_3[2][1] && massive_2[2][2] == massive_temp_3[2][2]) { cout << "Данный граф является изоморфным. Поиск завершен\n"; goto exit; } cout << "Перестановка столбцов завершена. \n";//неизменные строки /////////////////////////////////////////////////////////////////// cout << "Перестановка строки № 1 (первая со второй): \n"; swap(massive_temp_3[0][0], massive_temp_3[1][0]); swap(massive_temp_3[0][1], massive_temp_3[1][1]); swap(massive_temp_3[0][2], massive_temp_3[1][2]); if (massive_2[0][0] == massive_temp_3[0][0] && massive_2[0][1] == massive_temp_3[0][1] && massive_2[0][2] == massive_temp_3[0][2] && massive_2[1][0] == massive_temp_3[1][0] && massive_2[1][1] == massive_temp_3[1][1] && massive_2[1][2] == massive_temp_3[1][2] && massive_2[2][0] == massive_temp_3[2][0] && massive_2[2][1] == massive_temp_3[2][1] && massive_2[2][2] == massive_temp_3[2][2]) { cout << "Данный граф является изоморфным. Поиск завершен\n"; goto exit; } cout << "Перестановка № 1: \n"; swap(massive_temp_3[0][0], massive_temp_3[0][1]); swap(massive_temp_3[1][0], massive_temp_3[1][1]); swap(massive_temp_3[2][0], massive_temp_3[2][1]); for (int i = 0; i < number_node_temp_2; i++) { for (int j = 0; j < number_edge_temp_2; j++) { cout << "|"; cout << setfill('_'); cout << setw(3) << massive_temp_3[i][j]; } cout << setw(3) << "|N_" << i + 1 << "\n"; } if (massive_2[0][0] == massive_temp_3[0][0] && massive_2[0][1] == massive_temp_3[0][1] && massive_2[0][2] == massive_temp_3[0][2] && massive_2[1][0] == massive_temp_3[1][0] && massive_2[1][1] == massive_temp_3[1][1] && massive_2[1][2] == massive_temp_3[1][2] && massive_2[2][0] == massive_temp_3[2][0] && massive_2[2][1] == massive_temp_3[2][1] && massive_2[2][2] == massive_temp_3[2][2]) { cout << "Данный граф является изоморфным. Поиск завершен\n"; |