def add_edges_from(self, ebunch, attr_dict=None, **kwargs): """ same as above..but for many """ for e in ebunch: #because of area overlap we need to take one at a time super(ExtendedGraph,self).add_edges_from(ebunch=[e], attr_dict=attr_dict, attr=kwargs) dA=go.singleRoadSegmentCoverage((e[0],e[1]), self, add=True) self.areaCover+=dA*self.Ainv
def remove_edge(self, e1, e2): """ removes edge e from R and updates related statistics If more functionality is needed for your road-algorithm, override or write new function """ super(ExtendedGraph,self).remove_edge(u=e1,v=e2) dA=go.singleRoadSegmentCoverage((e1,e2), self, remove=True) self.areaCover-=dA*self.Ainv
def remove_edges_from(self, ebunch): """ removes edge e from R and updates related statistics If more functionality is needed for your road-algorithm, override or write new function """ for e in ebunch: #one at a time because of overlap-calculations.. dA=go.singleRoadSegmentCoverage((e[0],e[1]), self, remove=True) self.areaCover-=dA*self.Ainv super(ExtendedGraph,self).remove_edges_from(ebunch=[e])
def refinedCost(R, e, storeData=False): """ * cost of removing edge e in road net R, does not modify R but saves some shortest path information to save future computations, if storeData is set to True * Does not work for directed graphs right now. * Only works for "single origin" right now. * Needs testing and verification """ C=sumPathsDiff(R,e,storeData) C2=R.cr*go.singleRoadSegmentCoverage(e) return R.cd*C/R.density-C2