private void GreedyColoringImplementation(Queue <Vertex <T> > queueVertices) { //Sequential coloring of selected vertices. while (queueVertices.Count > 0) { var vertex = queueVertices.Dequeue(); var colorsCollection = new ColorsCollection(); var colors = colorsCollection.customColors; foreach (var nighber in vertex.Neighbors.FindAll(v => v.Color != null)) { if (nighber.Color != null) { colors.Remove((Color)nighber.Color); } } vertex.Color = colors.First(); } //OptimalColoring all remaining vertices foreach (var vertex in Vertices.FindAll(v => v.Color == null)) { var colorsCollection = new ColorsCollection(); var colors = colorsCollection.customColors; foreach (var nighber in vertex.Neighbors.FindAll(v => v.Color != null)) { if (nighber.Color != null) { colors.Remove((Color)nighber.Color); } } vertex.Color = colors.First(); //graphGrid.Children.OfType<Button>().Single(b => b.Name == vertex.Name).Background = new SolidColorBrush(colors.First()); } }
private void OptimalColoringImplementation() { foreach (var vertex in Vertices.FindAll(v => v.Color == null)) { var colorsCollection = new ColorsCollection(); var colors = colorsCollection.customColors; foreach (var nighber in vertex.Neighbors.FindAll(v => v.Color != null)) { if (nighber.Color != null) { colors.Remove((Color)nighber.Color); } } vertex.Color = colors.First(); } }