我是Graph-tool的新手,并在Graph上学习基本操作。下面的命令让我很困惑。
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> G=Graph(directed=False)
>>> from graph_tool.all import *
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
>>> G=Graph(directed=False)
>>> G.add_vertex()
<Vertex object with index '0' at 0x7f70714a00f0>
>>> G.add_vertex()
<Vertex object with index '1' at 0x7f70714a0210>
>>> G.add_vertex()
<Vertex object with index '2' at 0x7f70714a00f0>
>>> G.add_vertex()
<Vertex object with index '3' at 0x7f70714a0210>
>>> G.add_vertex()
<Vertex object with index '4' at 0x7f70714a00f0>
>>> G.add_vertex()
<Vertex object with index '5' at 0x7f70714a0210>
>>> G.add_vertex()
<Vertex object with index '6' at 0x7f70714a00f0>
>>> G.add_edge(1,2)
<Edge object with source '1' and target '2' at 0x7f7085fca9d0>
>>> print(G)
<Graph object, undirected, with 7 vertices and 1 edge at 0x7f70967c5400>
>>> G.clear_vertex(1)
>>> print(G)
<Graph object, undirected, with 7 vertices and 1 edge at 0x7f70967c5400>
>>> G.clear_vertex(2)
>>> print(G)
<Graph object, undirected, with 7 vertices and 1 edge at 0x7f70967c5400>
我知道clear_vertex是清除与Vertex相关的所有边。但是在执行clear_vertex之后,似乎Graph仍然包含之前创建的1个边。我需要修改我的代码吗?
谢谢
答案 0 :(得分:1)
这确实是一个错误,但我刚刚在git中修复过:
https://git.skewed.de/count0/graph-tool/commit/12fea4983ab98eae410a446f27ae5c0dd34cd90c
该错误大多无害,因为它只是在清除顶点时更新边缘计数失败。实际上删除了边缘。