Hi I'm using a Set backed by a HashMap to keep track of what edges I have already traversed in a graph. I was planning on keying the set by the result of adding the hashcodes of the data stored in each edge.
v.getData().hashCode() + wordV.getData().hashCode()
But how reliable is this when using contains to check to see if the edge is in the set? Couldn't I hypothetically get a false positive? Is there anyway to overcome this?
the exact statement that causes me concern is:
edgeSet.contains(v.getData().hashCode() + wordV.getData().hashCode())
thanks!
Oh by the way I'm using Java.
EDIT:
I should have made this clear in the question. In my graph there is no edge object, there are vertex objects which each hold a list of more vertex objects, which is the edge. So I guess the question that follows from that combined with your responses is:
Can I use a Set to store references to information as opposed to objects....? i.e. can I store the result of adding the two hashcodes for the vertices' data objects?
EDIT2:
I am indeed using the Java library for my hashmap, I declare it as below:
Set<Integer> edgeSet = Collections.newSetFromMap(new ConcurrentHashMap<Integer, Boolean>());