I am currently developing a browser-based application that allows users to create graphs, manipulate them, and run algorithms on them. At the moment, each vertex is represented by a unique positive integer. However, I am considering implementing labeled vertices, where the label can be any string. This presents a dilemma as to whether duplicate labels should be allowed and how they should be stored. Several options are being considered:
- Maintain integer vertex ids and enforce unique labels. This may lead to confusion between labels and vertex ids, particularly with JavaScript automatically converting numbers to strings.
- Stick with integer vertex ids but permit duplicate labels. While this offers more flexibility, it could also result in user confusion.
- Do away with numeric vertex ids entirely and identify vertices solely by their unique labels. But elevating something that seems like a property to an identifier doesn't feel quite right.
- Explore alternative approaches?
After researching various graph libraries, I've noticed that each has its own method for dealing with this issue. I understand that there may not be a definitive answer to my question, so I welcome opinions and insights. Thank you in advance!