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;
 }
Exemple #2
0
 public void AddNeighbour(Vertex neighbour)
 {
     neighbours[neighbour.Id] = neighbour;
 }
Exemple #3
0
 public void RemoveNeighbour(Vertex vertexToRemove)
 {
     if (neighbours.ContainsKey(vertexToRemove.Id))
         neighbours.Remove(vertexToRemove.Id);
 }
Exemple #4
0
 public void AddVertex(int id)
 {
     verticies[id] = new Vertex(id);
 }