Delete the directed edge (n1,n2,x) from the graph. Can be called either as >>> G.delete_edge(n1,n2,x) or as >>> G.delete_edge(e) where e=(n1,n2,x). If called with an edge e=(n1,n2), or as G.delete_edge(n1,n2) then the edge (n1,n2,None) will be deleted. If the edge does not exist, do nothing. To delete *all* edges between n1 and n2 use >>> G.delete_multiedges(n1,n2) Definition at line 1127 of file xbase.py. 01127 : """Delete the directed edge (n1,n2,x) from the graph. Can be called either as >>> G.delete_edge(n1,n2,x) or as >>> G.delete_edge(e) where e=(n1,n2,x). If called with an edge e=(n1,n2), or as G.delete_edge(n1,n2) then the edge (n1,n2,None) will be deleted. If the edge does not exist, do nothing. To delete *all* edges between n1 and n2 use >>> G.delete_multiedges(n1,n2) """ if n2 is None: # was called as delete_edge(e) if len(n1)==3: #case e=(n1,n2,x) n1,n2,x=n1 else: # assume e=(n1,n2) n1,n2=n1 # x=None if self.multiedges: # multiedges are stored as a list if (self.succ.has_key(n1) and self.succ[n1].has_key(n2) and x in self.succ[n1][n2]): self.succ[n1][n2].remove(x) # remove the edge item from list self.pred[n2][n1].remove(x) if len(self.succ[n1][n2])==0: # if last edge between n1 and n2 del self.succ[n1][n2] # was deleted, remove all trace del self.pred[n2][n1] else: # delete single edge if self.has_successor(n1,n2): del self.succ[n1][n2] del self.pred[n2][n1] return
