Re: [jgrapht-users] Node degree in the case of a looping edge
Brought to you by:
barak_naveh,
perfecthash
From: John V. S. <js...@gm...> - 2009-03-12 08:32:05
|
Thanks; this is definitely a bug (the test should be using equals instead of == in all cases). I've checked in the fix and unit test in Subversion. JVS Michaël Michaud wrote: > Hi, > > Maybe somebody can tell me if this behaviour is normal or if it's a bug. > I want to build a graph with a unique cycle (one edge, one vertex) > I use two classes MyVertex and MyEdge, a WeightedPseudograph (version > 0.7.3 of jGraphT), and here is my test case : > > v1 = new MyVertex(); > graph.addVertex(v1); > graph.addEdge(v1,v1,new MyEdge()); > ==> build a graph with 1 vertex and 1 edge, vertex has degree 2 (that is > OK!) > > v1 = new MyVertex(); > v2 = new MyVertex(); // where n2.equals(n1) > graph.addVertex(v1); > graph.addVertex(v2); > graph.addEdge(v1,v2,new MyEdge()); > ==> build a graph with 1 vertex and 1 edge, vertex has degree 4 ! > > Seems like addVertex uses equals to compare vertices and add only one > vertex if v1!=v2 but v1.equals(v2) > That's fine for me > There is still 1 vertex after addEdge, but that time, the degreeOf > method returns 4 instead of 2 > > I find this code in AbstractBaseGraph (line 1109) : > if (source != target) {getEdgeContainer(target).addEdge(e);} > //here == is used, not equals > and also this (line 1125) : > if (getEdgeSource(e).equals(getEdgeTarget(e))) { degree += 2;} > > Any help is welcome > > Michaël > > > > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > jgrapht-users mailing list > jgr...@li... > https://lists.sourceforge.net/lists/listinfo/jgrapht-users > |