algorithm - DFS 贪心色数

标签 algorithm graph depth-first-search greedy

在我的学校里,我了解到计算任意图的色数是 NP 完全的。 我明白为什么 greddy 算法不起作用,但是 DFS/Greedy 算法呢? 主要思想是对所有尚未着色的顶点进行 DFS,取所有邻居的最小颜色索引。

我想不出反例,这个问题让我大吃一惊。 感谢您的所有回答。

伪代码

Chromatic(Vertex x){
    for each neighbour y of vertex x
        if color(y) = -1
           color(y) <- minimum color over all the neighbours of y
           if(y>=numColor) numColors++;
           Chromatic(y);
}
Main(){
  Set the color of all vertex equal -1
  Take an arbitrary vertex u and set color(u) = 0
  numColors = 1;
  Chromatic(u);
  print numColors;
}

最佳答案

这是一个具体的反例:petersen graph 。无论你从哪里开始(我认为),你的算法都会计算 4,但图表的色度索引是 3。

enter image description here

彼得森图是图问题上许多贪婪尝试以及图论猜想的经典反例。

关于algorithm - DFS 贪心色数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36630881/

相关文章:

algorithm - Matlab 中的滑动窗口

算法:使用关联键重叠 1D 段

database - 是否有任何 FlockDB 教程站点

python - 如何更正此 python dfs 搜索?

algorithm - 将所选表行添加到数据库的最佳算法

c# - C# 中的斐波那契、二进制或二项式堆?

algorithm - 计算包含特定边集的生成树总数

python - 返回无向图中的顶点

algorithm - 我们可以使用哪种程序进行迷宫探索 BFS 或 DFS

java - 使用java进行深度优先搜索