BFS를 사용하여 그래프 색상을 구현할 수 있다고 생각하면 아래에 설명 된 접근 방법을 생각해 냈습니다.BFS를 사용한 그래프 채색 - 탐욕스러운 채색?
그래도 탐욕스러운 알고리즘처럼 보일 지 모르지만 그게 맞는지 나는 잘 모르겠다. 어떤 전문가의 의견?
colors[MAX_COLORS];
colorsUsedSoFar[] = NIL;
like BFS, color first node u with colors[0] i.e color[u] = colors[0];
colorsUsedSoFar[] += colors[0];
for each node v adjacent to u{
(if v not already colored){
color[v] = color from the colorsUsedSoFar[] but NotUsedByItsAdjacents
If all the colors in colorsUsedSoFar[] are used by adjacents, assign a new color to v)
}
}
'BFS와 마찬가지로'는 대기열을 사용하고 대기열이 소모 될 때까지 처리하는 것이 었습니다.
''그러나 NotUsedByItsAdjacents ''는 분명히 당신이 준수하려고하는 요구 사항이기 때문에 분명히 정확합니다. 최적/최소 색상 사용을 의미하지 않는 한, [위키 피 디아] (http://en.wikipedia.org/wiki/Greedy_coloring)와 동일하지 않습니다. – Dukeling