コード例 #1
0
ファイル: tree.py プロジェクト: conerade67/biana
 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
コード例 #2
0
ファイル: tree.py プロジェクト: zhaowei-1996/biana
 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
コード例 #3
0
ファイル: tree.py プロジェクト: conerade67/biana
 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)
コード例 #4
0
ファイル: tree.py プロジェクト: zhaowei-1996/biana
 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)