Re: [jgrapht-users] Doubt - Graph class / Weighted Graphs
Brought to you by:
barak_naveh,
perfecthash
From: John V. S. <js...@gm...> - 2006-11-15 21:55:36
|
These wiki pages may be helpful: http://jgrapht.wikispaces.com/message/view/home/88807 http://jgrapht.wikispaces.com/MigrationTo0.7 I'll send you a wikispaces invite so that if you want to share what you learn, you can update the migration page. JVS Anderson Adolfs wrote: > Due to some changes with Graph class provided with > JGraphT 0.7 lib, I am experiencing a problem. > > /* An example code using JGraphT 0.6 lib */ > > Graph graph = new WeightedPseudograph(); > > INode node1 = new Node2D(); > graph.addVertex(node1); > INode node2 = new Node2D(); > graph.addVertex(node2); > > MyEdge edge = new MyEdge(node1, node2, f); > edge.setWeight(feature.getGeometry().getLength()); > graph.addEdge(edge); > > /* In 0.7 lib these relations were modified, > * Graph class has no more this addEdge method. > * Using JGraphT 0.7 lib, I'm trying: > */ > > WeightedGraph graph = new WeightedPseudograph( > Edge.class ); > > INode node1 = new Node2D(); > graph.addVertex(node1); > INode node2 = new Node2D(); > graph.addVertex(node2); > > graph.setEdgeWeight(graph.addEdge(node1, node2), > feature.getGeometry().getLength()); > > /* But I got a RuntimeException: Edge Factory failed > */ > > java.lang.RuntimeException: Edge factory failed > at > org.jgrapht.graph.ClassBasedEdgeFactory.createEdge(Unknown > Source) > at > org.jgrapht.graph.AbstractBaseGraph.addEdge(Unknown > Source) > at > com.shortestpath.topology.GraphFactory.createGraph(GraphFactory.java:124) > at > com.shortestpath.jgraphtLib.PlugIn.run(PlugIn.java:101) > at > > com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager$TaskWrapper.run(TaskMonitorManager.java:118) > at java.lang.Thread.run(Thread.java:595) > Caused by: java.lang.InstantiationException: > com.shortestpath.topology.Edge > at java.lang.Class.newInstance0(Class.java:335) > at java.lang.Class.newInstance(Class.java:303) > ... 6 more > > I´ll be thankfull for any help. > > Anderson. |