The basic usage in the Graph-tool: how to delete vertex and related edges in the Graph-tool?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

The basic usage in the Graph-tool: how to delete vertex and related edges in the Graph-tool?

zhfkt
Hi All,

I am new to Graph-tool and learning the basic operation on the Graph. The below command confused me a lot.

---------------------------------------------

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.

>>> 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>

---------------------------------------------

I know the clear_vertex is to clear all edges related with the Vertex. But after executing the clear_vertex, it seems that the Graph still contains 1 edge created before. Will I need to revise my code ?

I post the same on the stackoverflow https://stackoverflow.com/questions/45031315/the-basic-usage-in-the-graph-tool-how-to-delete-vertex-and-related-edges-in-the?noredirect=1#comment77045641_45031315

Thank you,
Best Regards.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The basic usage in the Graph-tool: how to delete vertex and related edges in the Graph-tool?

Tiago Peixoto
Administrator
On 11.07.2017 16:00, zhfkt wrote:
> I know the clear_vertex is to clear all edges related with the Vertex. But
> after executing the clear_vertex, it seems that the Graph still contains 1
> edge created before. Will I need to revise my code ?

This is a simple bug hat has already been fixed in git.

The edges are actually deleted from the graph, but the counter is not updated.

You can check by doing: len(list(g.edges()))

The fix will be available in the next version, but in the meantime you can
just ignore it, or install from git.

> I post the same on the stackoverflow
> https://stackoverflow.com/questions/45031315/the-basic-usage-in-the-graph-tool-how-to-delete-vertex-and-related-edges-in-the?noredirect=1#comment77045641_45031315

It is redundant to post in stack overflow; the proper places are this
mailing list and the issue tracker in the website.

--
Tiago de Paula Peixoto <[hidden email]>


_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool

signature.asc (849 bytes) Download Attachment
--
Tiago de Paula Peixoto <tiago@skewed.de>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The basic usage in the Graph-tool: how to delete vertex and related edges in the Graph-tool?

zhfkt
In reply to this post by zhfkt
Thank you for quick clarification. I can have a good sleep tonight.




Loading...