Can a vertex store other information?


#1

Question

In the context of this exercise, can a vertex store other information, other than just its value and edges?

Answer

Yes, absolutely. One of the advantages of using an object representation over the adjacency matrix and adjacency list representations of a graph is the ability to store more information in each vertex, as they are objects.

Because each vertex is an object, you can implement them so that they contain any other information required. For example, if you were creating a graph modeling a social network, and each vertex represented a person, you could store their information like name, age, and education, along with their id and connections.