Quantcast

The code

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

The code

Vernon Smith

Hi, Barak,

The enclosed is the code for the problems I posted on JGraphT forum. The class layout is my original approach with a custom Vertex class, which is not the one in my application, but it yields the same exception. Please let me know hot to fix the problem.

Many thinks.

Vernon





____________________________________________________________
Enter for a chance to win one year's supply of allergy relief!
http://ad.doubleclick.net/clk;6413623;3807821;f?http://mocda3.com/1/c/563632/125699/307982/307982
This offer applies to U.S. Residents Only

R.java (303 bytes) Download Attachment
TestCase01.java (1K) Download Attachment
V.java (656 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: The code

Barak Naveh
Hi Vernon,

The problem is in your implementation of class V.

The class overrides the equals() method without overriding hashCode()
method. Doing it is against the contract of equals() and hashCode() methods,
and it confuses the HashSet class used internally by JGraphT.

This is a mistake that almost every Java programmer does only once. I'm
saying "once" because it usually takes enough time to find, to never forget
about it :).

Please read CAREFULLY the documentation of equals() and hashCode():
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html

The answers are coming ... ;)

All the best,
Barak


> -----Original Message-----
> From: [hidden email] [mailto:jgrapht-users-
> [hidden email]] On Behalf Of Vernon Smith
> Sent: Thursday, October 23, 2003 02:45
> To: [hidden email]
> Subject: [jgrapht-users] The code
>
>
> Hi, Barak,
>
> The enclosed is the code for the problems I posted on JGraphT forum. The
> class layout is my original approach with a custom Vertex class, which is
> not the one in my application, but it yields the same exception. Please
> let me know hot to fix the problem.
>
> Many thinks.
>
> Vernon
>




Loading...