Exemplo n.º 1
0
 def delete_edge(self, u, v=None): 
     if v is None: (u,v)=u   # no v given, assume u is an edge tuple
     Graph.delete_edge(self,u,v)
     # this will always break a tree into two trees
     # put nodes connected to v in a new component
     vnodes=component.node_connected_component(self,v)
     for n in vnodes:
         self.comp[n]=self.nc
     self.nc+=1
Exemplo n.º 2
0
 def delete_edge(self, u, v=None):
     if v is None: (u, v) = u  # no v given, assume u is an edge tuple
     Graph.delete_edge(self, u, v)
     # this will always break a tree into two trees
     # put nodes connected to v in a new component
     vnodes = component.node_connected_component(self, v)
     for n in vnodes:
         self.comp[n] = self.nc
     self.nc += 1
Exemplo n.º 3
0
 def delete_edge(self, u, v=None): 
     if v is None: (u,v)=u
     if self.degree(u)==1 or self.degree(v)==1: # leaf edge
         Graph.delete_edge(self,u,v)
     else: # interior edge
         raise NetworkXError(\
               "deleting interior edge %s-%s not allowed in tree"%(u,v))
     if self.degree(u)==0:  # OK to delete remaining isolated node
         Graph.delete_node(self,u)
     if self.degree(v)==0:  # OK to delete remaining isolated node          
         Graph.delete_node(self,v)
Exemplo n.º 4
0
 def delete_edge(self, u, v=None):
     if v is None: (u, v) = u
     if self.degree(u) == 1 or self.degree(v) == 1:  # leaf edge
         Graph.delete_edge(self, u, v)
     else:  # interior edge
         raise NetworkXError(\
               "deleting interior edge %s-%s not allowed in tree"%(u,v))
     if self.degree(u) == 0:  # OK to delete remaining isolated node
         Graph.delete_node(self, u)
     if self.degree(v) == 0:  # OK to delete remaining isolated node
         Graph.delete_node(self, v)