INNER CODE UNIT · Python

add_vertex

steineggerlab/Metabuli · util/gtdb_to_taxdump.py:82

    def add_vertex(self, vertex):
        """ If the vertex "vertex" is not in 
            self.__graph_dict, a key "vertex" with an empty
            list as a value is added to the dictionary. 
            Otherwise nothing has to be done. 
        """
        if vertex not in self.__graph_dict:
            self.__graph_dict[vertex] = []
            self.__graph_nodeIDs[vertex] = len(self.__graph_nodeIDs.keys())+1

    def add_edge(self, vertex1, vertex2):
        """ assumes that edge is of type set, tuple or list; 
            between two vertices can be multiple edges! 
        """
        try:
            self.__graph_dict[vertex1].append(vertex2)
        except KeyError:
            self.__graph_dict[vertex1] = [vertex2]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…