I have created a set of vertices 0-> 1-> 2 ->3 ->4 using the TreeLayout. Do anybody know how am I going to remove all the vertices that I have created. At the moment, I can use: graph.removeVertex(vertex1); But this will only remove vertex 1. And also when all these vertices are removed, the public String create() should reset to 0 again. Thank you for your help.
graph.getVertices() will get you a collection of all vertices in your graph. Now you can delete them one by one with graph.removeVertex(). Beware of ConcurrentModificationException when you're working with a set.
PS: btw, plx use the search function of the forum before you ask. I'm sure this question was answered before.
To answer the other half of your question, you can create a vertex factory that has any properties you want. Perhaps the easiest way to accomplish what you want is to pass in the Graph as a parameter to the Factory constructor, and then assign an index to the created vertex equal to the graph size.