### Question:
GreedyColoring implements VertexColoringAlgorithm<V> { @Override public Coloring<V> getColoring() { int maxColor = -1; Map<V, Integer> colors = new HashMap<>(); Set<Integer> used = new HashSet<>(); for (V v : getVertexOrdering()) { for (E e : graph.edgesOf(v)) { V u = Graphs.getOppositeVertex(graph, e, v); if (v.equals(u)) { throw new IllegalArgumentException(SELF_LOOPS_NOT_ALLOWED); } if (colors.containsKey(u)) { used.add(colors.get(u)); } } int candidate = 0; while (used.contains(candidate)) { candidate++; } used.clear(); colors.put(v, candidate); maxColor = Math.max(maxColor, candidate); } return new ColoringImpl<>(colors, maxColor + 1); } GreedyColoring(Graph<V, E> graph); @Override Coloring<V> getColoring();  }### Answer:
@Test public void testGreedy() { Graph<Integer, DefaultEdge> g = createGraph1(); Coloring<Integer> coloring = new GreedyColoring<>(g).getColoring(); assertEquals(3, coloring.getNumberColors()); Map<Integer, Integer> colors = coloring.getColors(); assertEquals(0, colors.get(1).intValue()); assertEquals(1, colors.get(2).intValue()); assertEquals(2, colors.get(3).intValue()); assertEquals(1, colors.get(4).intValue()); assertEquals(1, colors.get(5).intValue()); }