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

def Bio::Pathway::Rep::Graph::Graph::remove_node (   self,

Removes node and all edges connected to it.

Definition at line 115 of file Graph.py.

00115                                :
        """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 is not node,
        # 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),
            # remove the entry completely if the label is now unused
            if lm.empty():
                del self.__label_map[label]
                self.__label_map[label] = lm
        # remove all refering entries in edge map
        for edge in self.__edge_map.keys():
            if edge[0] is node or edge[1] is node:
                del self.__edge_map[edge]

Generated by  Doxygen 1.6.0   Back to index