(colors map[int]Color)
| 42 | } |
| 43 | |
| 44 | func (g *Graph) ValidateColorsOfVertex(colors map[int]Color) error { |
| 45 | if g.vertices != len(colors) { |
| 46 | return errors.New("coloring: not all vertices of graph are colored") |
| 47 | } |
| 48 | // check colors |
| 49 | for vertex, neighbours := range g.edges { |
| 50 | for nb := range neighbours { |
| 51 | if colors[vertex] == colors[nb] { |
| 52 | return errors.New("coloring: same colors of neighbouring vertex") |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | return nil |
| 57 | } |
no outgoing calls