Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- const int VERT_NUM = 7; // Wprowadź ilość wierzchołków
- const int COLOR_NUM = 3; // Wprowadź ilość kolorów
- const int EDG_NUM = 9; // Wprowadź ilość krawędzi
- int vertices[VERT_NUM] = {0};
- int edges[EDG_NUM][2];
- // Wprowadź wierzchołki kolejnych krawędzi (numeracja zaczyna się od 1)
- edges[0][0] = 1, edges[0][1] = 2; // 1. krawędź
- edges[1][0] = 1, edges[1][1] = 3; // 2. krawędź
- edges[2][0] = 1, edges[2][1] = 6; // ...
- edges[3][0] = 2, edges[3][1] = 5;
- edges[4][0] = 3, edges[4][1] = 6;
- edges[5][0] = 3, edges[5][1] = 4;
- edges[6][0] = 4, edges[6][1] = 5;
- edges[7][0] = 5, edges[7][1] = 6;
- edges[8][0] = 5, edges[8][1] = 7;
- bool right = true;
- int counter = 0;
- while (true)
- {
- for (int i = 0; i < EDG_NUM; i++)
- {
- if (vertices[edges[i][0] - 1] == vertices[edges[i][1] - 1])
- {
- right = false;
- break;
- }
- }
- if (right)
- {
- counter++;
- std::cout << "GRAF " << counter << std::endl;
- for (int i = 0; i < VERT_NUM; i++)
- std::cout << vertices[i] << ' ';
- std::cout << std::endl;
- }
- vertices[0]++;
- for (int i = 0; i < VERT_NUM - 1; i++)
- {
- if (vertices[i] == COLOR_NUM)
- {
- vertices[i] = 0;
- vertices[i + 1]++;
- }
- }
- if (vertices[VERT_NUM - 1] == COLOR_NUM)
- break;
- right = true;
- }
- std::cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement