On 11/09/2013 01:01 AM, vcongz wrote:
Dear Tiago,
Thanks, it works. But when I save the sub-graph, the new xml.gz file is still the original graph.
My code seems like: ############################################################ g = load_graph("g.xml.gz")
print g.num_vertices(), g.num_edges()
c = g.vertex_properties["com"]
target_com = [2,4,5]
new_g = GraphView(g, vfilt = lambda v: c[v] in target_com)
print new_g.num_vertices(), new_g.num_edges()
new_g.save("new_g.xml.gz") ############################################################ When I print the number of their edges and vertices, g and new_g have different number of edges and vertices. But, after saving the new_g, the new_g.xml.gz has same content with g.xml.gz.
What is the reason ? Thank you for your help!
The reason is that the filtered graph is just like the unfiltered graph, but with a filter on top. Filtering is a reversible operation, and can be removed at any time. If you want to delete the filtered vertices you can make: new_g.purge_vertices() Cheers, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>