Hi,
I created a graph few months ago using networkx where every node is a graph in itself. I pickled this graph.
Now I need to do some processing on this graph so I unpickled it as self.graph
For every node of this graph (which is a graph in itself), I want do some processing on the attribute 'street-wayid' of edges of this node(graph). I also need to call some functions from a different python file whose object has been created as OSM_data_obj. Here is what I am doing:
def process_node(self):
for n, d in self.graph.nodes_iter(data=True):
self.tempgraph=n
self.neighbour_IDs=[]
for u,v,p in self.tempgraph.edges_iter(data=True):
temp_way_ID= p['street-wayid']
temp_neighbour_IDs=[]
temp_coord_IDs = self.OSM_data_obj.way_dict[temp_way_ID][1] # Get the coord ID's contained in this way
temp_neighbour_IDs = self.OSM_data_obj.neighbouring_coord_IDs(temp_coord_IDs,50)
self.neighbour_IDs.extend(temp_neighbour_IDs)
This gives me 'self.neighbour_IDs' for every node n. I want to add this as a new attribute to every node for which this has been calculated in the existing graph. However, I am unable to do so. Do I have to create a new graph for this purpose?Or is there some way that I can add this information in the same for loop[for n,d in self.graph.nodes_iter]?
Many Thanks,