我试图在python代码中创建一个图形,我需要它在gephi中可视化。我尝试过这样的python代码:
from gephistreamer import graph
from gephistreamer import streamer
stream = streamer.Streamer(streamer.GephiWS())
node_a = graph.Node("A",custom_property=1)
node_b = graph.Node("B")
node_b.property['custom_property']=2
stream.add_node(node_a,node_b)
edge_ab = graph.Edge(node_a,node_b,custom_property="hello")
stream.add_edge(edge_ab)
My gephi Graph streaming plugin is active as master. When I run the python code, error occurs like this:
HandshakeError Traceback (most recent call last)
<ipython-input-1-7856b7437ce1> in <module>()
1 from gephistreamer import graph
2 from gephistreamer import streamer
----> 3 stream = streamer.Streamer(streamer.GephiWS())
4
5 # Create a node with a custom_property
/usr/local/lib/python2.7/dist-packages/gephistreamer/streamer.pyc in __init__(self, hostname, port, workspace)
113 self.workspace = workspace
114 self.websocket = self.Client(self._generate_url())
--> 115 self.websocket.connect()
116 def _generate_url(self):
117 return "ws://{hostname}:{port}/{workspace}?operation=updateGraph".format(hostname=self.hostname,
/usr/local/lib/python2.7/dist-packages/ws4py/client/__init__.pyc in connect(self)
235
236 try:
--> 237 self.process_response_line(response_line)
238 self.protocols, self.extensions = self.process_handshake_header(headers)
239 except HandshakeError:
/usr/local/lib/python2.7/dist-packages/ws4py/client/__init__.pyc in process_response_line(self, response_line)
300 protocol, code, status = response_line.split(b' ', 2)
301 if code != b'101':
--> 302 raise HandshakeError("Invalid response status: %s %s" % (code, status))
303
304 def process_handshake_header(self, headers):
HandshakeError:响应状态无效:404 Not Found
有人可以帮我这样做吗?
答案 0 :(得分:0)
我刚刚读到您的问题也在寻找解决方案。一些提示对我的运行很有帮助:
streamer.GephiWS(hostname="localhost", port=8080, workspace="workspace0")
http://localhost:8080/workspace0
8080