python - Graph-Tool GraphView Object -


i have filtered graph generated using graph-tool's graphview().

g = gt.graphview(g, vfilt= label_largest_component(g, directed=false)) 

the original graph g has 10,069 vertices while resulting graph has 9,197. however, using new (filtered) graph, when list in-degrees using indeg = g.degree_property_map("in"), total number of elements in list(indeg.a) still 10,069. becomes problematic when plotting new filtered graph 9,197 nodes vertex sizes set function of indeg, because of mismatched number of elements.

the code snippet looks this

g = load_graph("ppnet.xml") g = graphview(g, vfilt=label_largest_component(g, directed=false)) indeg = g.degree_property_map("in") indeg.a = np.sqrt(indeg.a) + 2 graph_draw(g, vertex_size = indeg, vertex_fill_color=indeg, pos = sfdp_layout(g),     vcmap=plt.cm.gist_heat, output_size=(400, 400), output="gc.png") 

which when run, gives following valueerror

valueerror: operands not broadcast shapes (10069,) (9197,)  

what proper way add intended style graphview objects?

found solution. first created copy of graphview object , purged vertices of copy. note instead of retaining variable name g, introduced new variable gc clarity.

g = load_graph("ppnet.xml") gc = graphview(g, vfilt=label_largest_component(g, directed=false)).copy() gc.purge_vertices() indeg = gc.degree_property_map("in") indeg.a = np.sqrt(indeg.a)+2 graph_draw(gc, vertex_size = indeg, vertex_fill_color=indeg, pos = sfdp_layout(gc),     vcmap=plt.cm.gist_heat, output_size=(400, 400), output="gc.png") 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -