gpt4 book ai didi

java - graphstream 中多重图的异常

转载 作者:行者123 更新时间:2023-11-30 06:36:04 25 4
gpt4 key购买 nike

如果有多个边缘,我正在努力显示两个节点上的两条边缘。我正在关注这个example 。但我遇到了一个异常(exception):

Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/convert/WrapAsScala at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at org.graphstream.ui.view.Viewer.newGraphRenderer(Viewer.java:349) at org.graphstream.graph.implementations.AbstractGraph.display(AbstractGraph.java:753) at org.graphstream.graph.implementations.AbstractGraph.display(AbstractGraph.java:747) at com.h2Database.app.ahd.main(ahd.java:18) Caused by: java.lang.ClassNotFoundException: scala.collection.convert.WrapAsScala at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 6 more

我的代码是:

import org.graphstream.graph.*;
import org.graphstream.graph.implementations.*;
import org.graphstream.ui.view.Viewer;

public class ahd {
public static void main(String args[]) {
Graph graph = new MultiGraph("Test");
System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
graph.addNode("A");
graph.addNode("B");

graph.addEdge("1", "A", "B", true);
graph.addEdge("2", "A", "B", true);

Viewer viewer = graph.display();
}
}

知道为什么我会面临这个吗?看来在给定的示例中这个问题已经解决了。

最佳答案

GraphStream v1.3 is comprised of三个 jar 文件:

$ ls -1 lib/*1.3.jarlib/gs-algo-1.3.jarlib/gs-core-1.3.jarlib/gs-ui-1.3.jar

J2DGraphRenderer 及其内部类可以在 gs-ui-1.3.jar 中找到:

$ jar tf lib/gs-ui-1.3.jar | grep org.graphstream.ui.j2dviewer.J2DGraphRendererorg/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$render$2.classorg/graphstream/ui/j2dviewer/J2DGraphRenderer.classorg/graphstream/ui/j2dviewer/J2DGraphRenderer$.classorg/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$render$2$$anonfun$apply$1.classorg/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$removeRenderers$1.classorg/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$render$1.classorg/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$removeRenderers$3.classorg/graphstream/ui/j2dviewer/J2DGraphRenderer$$anonfun$removeRenderers$2.class

验证运行时 gs-ui-1.3.jar 是否位于类路径中:

$ javac -cp .:lib/* ahd.java $ java -cp .:lib/* ahd

image

请注意classpath syntax is OS-dependent .

关于java - graphstream 中多重图的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45189550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com