// Java /****************************************** use variable graph to access Graph methods (e.g. graph.getVertexCount()) Goto http://www.inf.ethz.ch/~braendle/graphbench for Java API ******************************************/ import ch.ethz.graphbench.toolbox.*; // import Color class import java.awt.Color; public class ColorVertices extends GraphAlgorithm{ // Array with all the Colors to be used Color[] colors = new Color[] {Color.red, Color.yellow, Color.green, Color.blue, Color.cyan, Color.magenta, Color.orange}; public void executeAlgorithm(){ Vertex vertex; // go trhough all vertices for(int i=0; i < graph.getVertexCount(); i++){ // get the next Vertex vertex = graph.getVertex(i); // get the next Color Color color = colors[i % colors.length]; // set Color vertex.setColor(color); } } }