-1
我開始知道圖着色算法是NP-Complete問題。不過,我想知道是否可以使用啓發式方法實現任何實現,特別是區別圖着色?如果可能的話,是否有任何合適的資源來了解這一點?圖着色算法的實現
我開始知道圖着色算法是NP-Complete問題。不過,我想知道是否可以使用啓發式方法實現任何實現,特別是區別圖着色?如果可能的話,是否有任何合適的資源來了解這一點?圖着色算法的實現
如在稍微related post討論:
約束解算器等MiniZinc能夠解決廣泛的圖着色的問題。
這MiniZinc示例演示Petersen graph的着色:
% Petersen Graph
set of int: Colors = 1..3;
set of int: Nodes = 1..10;
set of int: Edges = 1..15;
array[Edges] of Nodes: aFrom = [ 1, 2, 3, 4, 1, 1, 2, 3, 4, 5, 6, 7, 7, 8, 6 ];
array[Edges] of Nodes: aTo = [ 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 8, 10, 9, 10, 9 ];
array[int] of string: colorName = [ "red", "green", "blue", "purple", "yellow", "brown", "black" ];
array[Nodes] of var Colors: nodeColor;
constraint
forall(e in Edges) (
nodeColor[aFrom[e]] != nodeColor[aTo[e]]
);
solve satisfy;
output [ show(colorName[nodeColor[n]]) ++ "\n" | n in Nodes ];