Dear all,
As far as I recall (and I'm happy to be wrong) overriding hash code for
Edge leads to Bad Things (tm). JGraphT is a general graph
implementation. As such, it doesn't assume that you're graph is not a
multigraph.
In the JGraphT implementation, if we add edge e between vertex
v1 and v2 we -- unsurprisingly -- have an edge between v1 and v2. If I
create another edge, e', which is between v1 and v2 and identical to e
in all other respects, then my graph has two edges, e and e', between
v1 and v2. By overriding hashCode, e and e' would be equal edges and
you'd only have one edge between v1 and v2.
I hope the above helps. I'll read it again after my first
coffee to see if it's actually intelligible.
--
Dr Aidan Delaney
Principal Lecturer
Computing, Engineering & Maths
University of Brighton
@aidandelaney
|