Re: [jgrapht-users] DirectedGraph equality testing
Brought to you by:
barak_naveh,
perfecthash
From: John S. <js...@gm...> - 2015-08-12 23:56:30
|
For multigraphs, e1 and e2 may both have source v1 and target v2, and yet they are two distinct edges. In general, "equality" for a graph isn't a very useful concept due to the fact that g1 and g2 may be isomorphic even though !g1.equals(g2). On Wed, Aug 12, 2015 at 2:30 PM, Aidan Delaney < ai...@on...> wrote: > Dear all, > I've been trying to test for deep vertex & edge equality in a > DirectedGraph. An example is below. It appears that this fails > because, I think, DefaultEdge needs a non-default hashCode > implementation. My GitHub pull-request is at [1], but it causes more > problems than it solves. > > Am I just incorrect in trying to use JGraphT in this way to check graph > equality? Is there some other way I should be doing this? > > DirectedGraph<String, DefaultEdge> g1 = > new SimpleDirectedGraph<String, > DefaultEdge>(DefaultEdge.class); > DirectedGraph<String, DefaultEdge> g2 = > new SimpleDirectedGraph<String, > DefaultEdge>(DefaultEdge.class); > > g1.addVertex("A"); > g2.addVertex("A"); > > assertEquals(g1, g2); > > g1.addVertex("B"); > g2.addVertex("B"); > > assertEquals(g1, g2); > > [1] https://github.com/jgrapht/jgrapht/pull/148 > > -- > Dr Aidan Delaney > Principal Lecturer > Computing, Engineering & Maths > University of Brighton > > @aidandelaney > > > ------------------------------------------------------------------------------ > _______________________________________________ > jgrapht-users mailing list > jgr...@li... > https://lists.sourceforge.net/lists/listinfo/jgrapht-users > |