Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool isSafe(int node, int c) {
- for (int i = 0; i < v[node].size(); i++)
- if (v[node][i] && c == color[i]) {
- return false;
- }
- return true;
- }
- bool graph_coloring(int m, int node) {
- for (auto i : v[node]) {
- for (int c = 1; c <= m; c++) {
- if (isSafe(node, c)) {
- color[node] = c;
- if (graph_coloring(m, i)) {
- return true;
- }
- color[node] = 0;
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement