Пример #1
0
// Update node color and udpate colors info on adjacents
func updateColorAndAdj(node *graph.Node, newColor graph.NodeColor, h *nh.Heap) bool {
	anyZeroed := false
	for _, adj := range node.Adj {
		adj.NeighborGotColor(newColor)
		anyZeroed = anyZeroed || adj.NumTaken == graph.NumColors-1
	}
	if Heuristic.MRV {
		heap.Init(h)
	}
	node.Color = newColor

	return anyZeroed
}
Пример #2
0
func resetColorAndAdj(node *graph.Node) {
	for _, adj := range node.Adj {
		adj.NeighborLostColor(node.Color)
	}
	node.Color = graph.Blank
}