Re: [jgrapht-users] bug in graph?
Brought to you by:
barak_naveh,
perfecthash
From: John S. <js...@gm...> - 2011-08-12 01:21:40
|
http://pub.eigenbase.org/wiki/JGraphT:EqualsAndHashCode On Thu, Aug 11, 2011 at 2:22 PM, Bagwell, Allen F <af...@sa...> wrote: > I believe I’ve found a bug. I get the IllegalArgumentException whether I > invoke outgoingEdgesOf(vertex) or incomingEdgesOf(vertex). And this only > happens after I modify a simple field in my vertex object. > > If rn == TESTNODE evaluates to true after modifying the node’s string field, > then the offending method should not be throwing an exception saying the > vertex isn’t in the graph. > > -Allen > > > SimpleDirectedWeightedGraph<RiskNode, DefaultWeightedEdge> graph = new > SimpleDirectedWeightedGraph<RiskNode, > DefaultWeightedEdge>(DefaultWeightedEdge.class); > RiskNode TESTNODE = new RiskNode("TEST",""); > if (!graph.addVertex(TESTNODE)) > fail("Didn't add TEST node."); > > for (RiskNode rn : graph.vertexSet()) { > if (rn.equals(TESTNODE)) > System.out.println("#1: found it"); > if (rn == TESTNODE) > System.out.println("#1: they are the same object"); > else > System.out.println("#1: they are different objects"); > } > > System.out.println("Number of outgoing edges = " + > graph.outgoingEdgesOf(TESTNODE).size()); > > TESTNODE.setDescription("adding a description..."); > > for (RiskNode rn : graph.vertexSet()) { > if (rn.equals(TESTNODE)) > System.out.println("#2: found it"); > if (rn == TESTNODE) > System.out.println("#2: they are the same object"); > else > System.out.println("#2: they are different objects"); > } > > System.out.println("Number of outgoing edges = " + > graph.outgoingEdgesOf(TESTNODE).size()); > > ----- Output from running code: > > #1: found it > #1: they are the same object > Number of outgoing edges = 0 > #2: found it > #2: they are the same object > > java.lang.IllegalArgumentException: no such vertex in graph > at org.jgrapht.graph.AbstractGraph.assertVertexExist(Unknown Source) > at > org.jgrapht.graph.AbstractBaseGraph$DirectedSpecifics.getEdgeContainer(Unknown > Source) > at > org.jgrapht.graph.AbstractBaseGraph$DirectedSpecifics.outgoingEdgesOf(Unknown > Source) > at org.jgrapht.graph.AbstractBaseGraph.outgoingEdgesOf(Unknown > Source) > at > gov.sandia.analysis.TestRiskAnalysis.testChangeVertex(TestRiskAnalysis.java:385) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) > at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) > at > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) > at > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) > at > org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) > at > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) > at org.junit.runners.ParentRunner.run(ParentRunner.java:236) > at > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) > at > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) > > > ------------------------------------------------------- > Allen F. Bagwell > Sandia National Laboratories - CA > Systems Modeling & Software Engineering, Org. 8116 > af...@sa... > TEL: (925) 294.4756 > FAX: (925) 294.3870 > > > > ------------------------------------------------------------------------------ > Get a FREE DOWNLOAD! and learn more about uberSVN rich system, > user administration capabilities and model configuration. Take > the hassle out of deploying and managing Subversion and the > tools developers use with it. > http://p.sf.net/sfu/wandisco-dev2dev > _______________________________________________ > jgrapht-users mailing list > jgr...@li... > https://lists.sourceforge.net/lists/listinfo/jgrapht-users > > |