图论-色指数
我必须编写一个程序来说明图形是否可着色 - 基本上我必须检查色索引是 d 还是 d+1,其中 d 是所有顶点的最大度数(维辛定理)。我知道这个问题是 NP 完全问题,基本上必须通过暴力破解。我有一个想法,但不知道它是否正确 -
1)找到 deg(v) = d 的顶点,并将与 v 相关的所有边用 d 不同的颜色着色。
2) 对于与 v 相邻的顶点相关的所有边,应用 d 组颜色中的一些颜色
3) 对于“发现的”边重复 2)
如果所有边都用 d 种颜色着色,则色度索引为 d 并且 i 有一种着色图 G 的。
如果某些边不能用 d 组颜色中的颜色着色,则用 d+1 种颜色为他着色,并用 d+1 组颜色中的颜色为剩余边着色 - 这是问题 - 使用此方案,如果我宣布色度指数为 d+1,是否有可能使用其他一些着色色度指数为 d? (对于每条要着色的边,我选择一种可以使用的颜色)..
另外,哪种图形表示最适合这个问题?在输入文件中,图被写入邻接矩阵中。我知道可以用递归来解决,但我不知道如何解决。我陷入了一些过于复杂的想法:S(一些提示或伪代码将不胜感激)。
编辑:
刚刚想到,我认为应该没问题(纯粹的暴力)。我还没有尝试实现这个。如果您看到有什么不对的地方请评论。再说一遍 - 算法应该检查图是否可以用 d 或 d+1 种颜色进行边缘着色,其中 d 是给定简单图中所有顶点的最大度数,并找到一种着色...
colorEdge(edge, color, extra) {
if (edge colored) return; //if already colored, return
if (can be colored in color) color it; //if color can be applied, apply it
else {
//else, 'd+1'-st color neded, so color it with that color, continue finding
//coloring with d+1 colors
extra = true;
color it in color extra;
}
//recursivly try to color adjacent edges with available colors
for each color c' from set of d colors {
for each edge k adjacent to current {
colorE(k, c', extra)
}
}
}
//main
bool extra = false;
for each color b from set of d colors {
colorEdge(some starting edge, b, extra)
if (!extra) break;
}
I have to make a program which will say if graph is d colorable or not - basically i have to check if chromatic index is d or d+1, where d is max degree of all vertices (vizing's theorem). I know this problem is NP-complete and basically it has to be bruteforced. I had an idea but don't know if it is correct -
1) find vertex with deg(v) = d and color all edges incident with v with d distnict colors.
2) for all edges incident with vertices which are adjacent to v, apply some color from set of d colors
3) repeat 2) for "discovered" edges
If all edges are colored with d colors, chromatic index is d and i have one coloring of graph G.
If some edge can't be colored with color from set of d colors, color him with d+1-st color and color remaining edges with colors from set of d+1 colors - here is the question - using this scheme, if i proclaim that chromatic index to be d+1, is there a chance that with some other coloring chromatic index would be d? (for every edge that is going to be colored I'm choosing one color which can be used)..
Also, which graph representation would be best for this problem? In input file graph is written in adjacency matrix. i know it can be solved with recursion, but I don't have an idea how. I'm stuck with some too complicated ideas :S (some hint or pseudocode would be appreciated).
Edit:
Just came across my mind, I think it should be ok (pure bruteforce). I didnt try to implement this yet. Please comment if you see something wrong. Just to say again - algorithm should check whether graph is edge colorable with d or d+1 colors where d is max degree of all vertices in given simple graph, and to find one coloring...
colorEdge(edge, color, extra) {
if (edge colored) return; //if already colored, return
if (can be colored in color) color it; //if color can be applied, apply it
else {
//else, 'd+1'-st color neded, so color it with that color, continue finding
//coloring with d+1 colors
extra = true;
color it in color extra;
}
//recursivly try to color adjacent edges with available colors
for each color c' from set of d colors {
for each edge k adjacent to current {
colorE(k, c', extra)
}
}
}
//main
bool extra = false;
for each color b from set of d colors {
colorEdge(some starting edge, b, extra)
if (!extra) break;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为每条边生成约束,为具有最多边的顶点的所有边分配不同的颜色,然后从受约束最多的边开始处理每条边。
将最受约束的边缘定义为具有最多已分配颜色的周围边缘可能是一个好主意,但这可能会导致相当多的开销。
Generate constraints for each edge, assign different colours to all edges of the vertex with the most edges and then process each edges from the most constrained edge.
It may be a good idea to defined the most constrained edge as the one with the most surrounding edges that have already been assigned colours, but this could cause quite a bit of overhead.
将图形转换为使用顶点着色算法非常简单:对于原始图形中的每条边 (x,y) 在转换后的图形中创建一个顶点 xy,并且对于原始图中的每个顶点 x 都会在名称中包含 x 的转换图中的所有顶点之间创建边。
干杯
transforming your graph to use the vertex coloring algorithm is quite straightforward: for each edge (x,y) in the original graph create a vertex xy in the transformed graph, and for each vertex x in the original graph create edges between all vertices in the transformed graph containing x in their name.
Cheers