1. 问题
图的m着色问题。给定无向连通图G和m种颜色,用这些颜色给图的顶点着色,每个顶点一种颜色。如果要求G的每条边的两个顶点着不同颜色。给出所有可能的着色方案;如果不存在,则回答“NO”。
2. 解析
3. 分析
最坏时间复杂度: O(n*m^n)
4. 设计
#include<bits/stdc++.h>
using namespace std;
int n, m,a = 1, b = 1,cnt;
int graph[20][20],color[20];
bool check(int x) {
for (int i = 1; i <= n; i++)
if (graph[x][i] && color[x] == color[i])
return false;
return true;
}