Hi,I want to assign a name to the nodes i created but I am unable to do this.Can anyone tell me how to do this.

After you create a Graph object, you may use the addVertex() method to create nodes in your graph.

Graph<Integer, String> g = new SparseMultigraph<Integer, String>();
g.addVertex((Integer)1);
g.addVertex((Integer)2);
g.addEdge("Edge-A", 1, 2);

The following code creates 2 nodes and an edge between them. By default, all the labels appear.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.