private bool TryColoring(Vertex vertex) { foreach (var neighbour in vertex.AllNeighbours) { if (!vertexColors[neighbour.Id].HasValue) { vertexColors[neighbour.Id] = GetOther(vertexColors[vertex.Id].Value); var reslut = TryColoring(neighbour); if (reslut == false) return false; } else if (vertexColors[vertex.Id] == vertexColors[neighbour.Id]) return false; } return true; }
public void AddNeighbour(Vertex neighbour) { neighbours[neighbour.Id] = neighbour; }
public void RemoveNeighbour(Vertex vertexToRemove) { if (neighbours.ContainsKey(vertexToRemove.Id)) neighbours.Remove(vertexToRemove.Id); }
public void AddVertex(int id) { verticies[id] = new Vertex(id); }