-3

I am unable to make a function/method for adding a vertex with 4 attributes in Java namely age, name, maritalStatus and index, where the new vertex needs to inserted in the specified index.

Can someone please guide me how to go about this?

How do I store these details; in the form of adjacency matrix, adjacency list or arraylist?

Michaël
  • 3,679
  • 7
  • 39
  • 64
pratzy
  • 93
  • 1
  • 1
  • 4

1 Answers1

0

You use a class for memorizing the atributes(ex class Human). And then you put the objects that you create in an ArrayList.

cristi
  • 361
  • 3
  • 9
  • @cristi... other than these attributes we have source and destination vertices and weights for the edges. How will I then work with them if I am making a Human class? – pratzy Nov 17 '12 at 07:17
  • The idea is to make objects with this attributes, and put this objects in a List or Map. If you are sure that each vertex has a unique index than you can use a List to memorize the objects. If two vertexes can have the same index, I recomand you to use a Map to store the objects – cristi Nov 17 '12 at 10:50