gpt4 book ai didi

java - GraphStream - 使用 netstream 的问题

转载 作者:太空宇宙 更新时间:2023-11-04 11:42:30 25 4
gpt4 key购买 nike

我正在使用以下代码中给出的标准示例,但 java 应用程序返回以下错误:

[//NetStreamDecoder | NetStreamReceiver: Don't know this command: 0]

我一直在编译 java 示例:

javac -cp lib/gs-core-1.2.jar:. ExampleReceiver.java

而 C++ 发送方是 https://github.com/graphstream/gs-netstream 中提供的发送方.我如何才能在 Java 应用程序中看到更新?提前致谢。

Example.java

import java.io.IOException;
import java.net.UnknownHostException;

import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.MultiGraph;
import org.graphstream.stream.netstream.packing.Base64Unpacker;
import org.graphstream.stream.netstream.NetStreamReceiver;
import org.graphstream.stream.thread.ThreadProxyPipe;

public class ExampleReceiver {

public static void main(String[] args) throws UnknownHostException, IOException, InterruptedException {

Graph g = new MultiGraph("G",false,true);
g.display();
NetStreamReceiver net = new NetStreamReceiver(2001);

ThreadProxyPipe pipe = net.getDefaultStream();
pipe.addSink(g);
while (true) {
pipe.pump();
Thread.sleep(100);
}
}
}

gs-netstream/cpp/src/netstream-main.cpp

void events_test(){
string source_id="C++_netstream_test";
long time_id=0L;
NetStreamSender stream("localhost", 2001);
stream.addNode(source_id, time_id++, "node0");
stream.addEdge(source_id, time_id++, "edge", "node0", "node1", true);
stream.addNodeAttribute(source_id, time_id++, "node0","nodeAttribute", 0);
stream.changeNodeAttribute(source_id, time_id++, "node0","nodeAttribute",0, 1);
stream.removeNodeAttribute(source_id, time_id++, "node0","nodeAttribute");
stream.addEdgeAttribute(source_id, time_id++, "edge","edgeAttribute", 0);
stream.changeEdgeAttribute(source_id, time_id++, "edge","edgeAttribute", 0,1);
stream.removeEdgeAttribute(source_id, time_id++, "edge","edgeAttribute");
stream.addGraphAttribute(source_id, time_id++, "graphAttribute", 0);
stream.changeGraphAttribute(source_id, time_id++, "graphAttribute", 0, 1);
stream.removeGraphAttribute(source_id, time_id++, "graphAttribute");
stream.stepBegins(source_id, time_id++, 1.1);
stream.removeEdge(source_id, time_id++, "edge");
stream.removeNode(source_id, time_id++, "node0");
stream.graphClear(source_id, time_id++);
}

最佳答案

NetStream的C++和python版本与gs-core 1.2版本的实现不同步。我们必须更新 C++ 和 python 实现。

与此同时,您可以使用旧版本的 gs-core。我建议从 github 存储库中检查修订版 a3f70d2。

关于java - GraphStream - 使用 netstream 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20829091/

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