2017-07-11 8 views
1

私はグラフツールを初めて使い、グラフの基本操作を学びました。以下のコマンドは私をたくさん混乱させました。グラフツールの基本的な使い方:グラフツールの頂点と関連するエッジを削除する方法は?

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は、頂点に関連するすべてのエッジをクリアすることがわかります。しかし、clear_vertexを実行すると、グラフには前に作成された1つのエッジが含まれているようです。コードを改訂する必要がありますか?

は、これは確かにバグですあなた

+0

私はあなたのコードを実行して同じ結果を得ましたが、 'G.get_edges()'を呼び出すと空の配列が得られるので、これは文字列表現のバグですより深刻な結果をもたらさないかもしれない)。 – jdehesa

+0

私が心配しているのは、グラフツールを使用したことがないので、私がこのコードに合っているとは言えません。コメントをいただきありがとうございます。 @jdehesa – zhfkt

+0

G.clear_edges()もうまく動かず、印刷(G)にまだエッジが存在することがわかりました。 – zhfkt

答えて

関連する問題