[jgrapht-users] Documentation, implementation or me?
Brought to you by:
barak_naveh,
perfecthash
From: Jonathan C. <jon...@it...> - 2010-11-16 01:41:11
|
I am a huge fan of jgrapht. However, I have come across a problem with it. My understanding is that that the code below should work, but it doesn't. I have not dug into the source, but I can imagine that there is a hashcode issue, as it no longer seem to find the vertex that is there. I am not sure if I have read the docs wrong, programmed wrong, or if this is simply a bug. The latter seems unlikely though, since it is such a core feature that this type of problem should have been caught long ago. Thanks in advance for any help! /Jonathan import java.util.LinkedHashSet; import java.util.Set; import org.jgrapht.graph.DefaultEdge; import org.jgrapht.graph.SimpleGraph; public class Main { /** * @param args */ public static void main(String[] args) { SimpleGraph<Set<String>, DefaultEdge> sg = new SimpleGraph<Set<String>, DefaultEdge>(DefaultEdge.class); Set<String> s1, s2; s2 = new LinkedHashSet<String>(); s2.add("y"); s2.add("z"); sg.addVertex(s2); s2.remove("z"); // this is true, as expected assert(sg.vertexSet().size()==1) : "There is no vertex any more."; assert(sg.vertexSet().iterator().next()==s2) : "Not the same vertex!"; // but this is false! assert(sg.containsVertex(s2)) : "The vertex is gone!"; } } |