Logo Search packages:      
Sourcecode: python-biopython version File versions

def Bio::Pathway::Rep::MultiGraph::MultiGraph::remove_node (   self,
  node 
)

Removes node and all edges connected to it.

Definition at line 110 of file MultiGraph.py.

00110                                :
        """Removes node and all edges connected to it."""
        if not self.__adjacency_list.has_key(node):
            raise ValueError, "Unknown node: " + str(node)
        # remove node (and all out-edges) from adjacency list
        del self.__adjacency_list[node]
        # remove all in-edges from adjacency list
        for n in self.__adjacency_list.keys():
            self.__adjacency_list[n] = HashSet(filter(lambda x,node=node: x[0] is not node,
                                                      self.__adjacency_list[n].list()))
        # remove all refering pairs in label map
        for label in self.__label_map.keys():
            lm = HashSet(filter(lambda x,node=node: \
                                (x[0] is not node) and (x[1] is not node),
                                self.__label_map[label].list()))
            # remove the entry completely if the label is now unused
            if lm.empty():
                del self.__label_map[label]
            else:
                self.__label_map[label] = lm


Generated by  Doxygen 1.6.0   Back to index