[graph-tool-tickets] [graph-tool] Ticket #119: New Property maps of wrong size after deleting vertices

graph-tool webmaster at skewed.de
Tue Dec 4 11:58:00 UTC 2012


#119: New Property maps of wrong size after deleting vertices
new defect
---------------------------------------------------------------------
Reporter: oleguer.sagarra at gmail.com
Owner: tiago peixoto
Priority: normal
Milestone: (None)
---------------------------------------------------------------------
Changes (by tiago peixoto (2)): 

 * Description:
 When applying "g.remove_edge_if" the resulting graph gives wrong
 shaped property maps.
 
 {{{
 #!python
 
 In [51]: # Network
 
 In [52]: g=gt.price_network(100) #100 edges
 
 In [53]: # NEw edge prop
 
 In [54]: b=g.new_edge_property('int')
 
 In [55]: from numpy import random as rd
 
 In [56]: # Random values for the prop
 
 In [57]: aux_b=rd.randint(low=0, high=100, size=g.num_edges())
 
 In [58]: b.a=aux_b
 
 In [59]: g.edge_properties['Rand']=b
 
 In [60]: g.num_vertices()
 Out[60]: 100
 
 In [61]: g.num_edges()
 Out[61]: 99
 
 In [62]: f= lambda x: g.edge_properties['Rand'][x]>10
 
 In [63]: g.remove_edge_if(f)
 
 In [64]: g.num_edges() # edges have changed
 Out[64]: 11
 
 In [65]: new_b=aux_b[aux_b<=10]
 
 In [66]: b_new=g.new_edge_property('int')
 
 In [67]: b_new.a=new_b
 ---------------------------------------------------------------------------
 ValueError                                Traceback (most recent
 call last)
 /home/physcomp2/<ipython-input-67-1bb6ad313195> in <module>()
 ----> 1 b_new.a=new_b
 
 /usr/local/lib/python2.7/dist-packages/graph_tool/__init__.pyc in
 __set_array(self, v)
     493         if a is None:
     494             return
 --> 495         a[:] = v
     496
     497     a = property(get_array, __set_array,
 
 ValueError: operands could not be broadcast together with shapes
 (99) (11)
 
 
 In [68]: # But if one saves and reloads...
 
 In [69]: g.save('./net.xml')
 
 In [70]: g=gt.load_graph('./net.xml')
 
 In [71]: b_new=g.new_edge_property('int')
 
 In [72]: b_new.a=new_b
 
 In [73]: # All good
 
 }}}

--
Ticket URL: <URL:http://graph-tool.skewed.de/ticket/119>
graph-tool <URL:http://graph-tool.skewed.de/>
An efficient python module for graph analysis and manipulation.


More information about the graph-tool-tickets mailing list