Пример #1
0
 def insertNode(self, elem):
     newnode = super().insertNode(elem)
     if self.nodes == None:  #crea nuovi dizionari
         self.nodes = {newnode.index: newnode}
         self.inc = {newnode.index: List()}
     else:  #aggiungi ai dizionari esistenti
         self.nodes[newnode.index] = newnode
         self.inc[newnode.index] = List()
     return newnode
    def insertNode(self, elem):
        newnode = super().insertNode(elem)
        if self.nodes == None:
            self.nodes = {newnode.index : newnode}   #inizializza dizionario
            self.adj = {newnode.index : List()}
        else:
            self.nodes[newnode.index] = newnode   #aggiungi nodo al dizionario
            self.adj[newnode.index] = List()

        return newnode
Пример #3
0
    def addNode(self, elem):
        """
        Add a new node with the specified value.
        :param elem: the node value.
        :return: the create node.
        """
        newnode = super().addNode(elem) # create a new node with the correct ID

        self.nodes[newnode.id] = newnode # add the new node to the dictionary
        self.inc[newnode.id] = List() # create the incidence list for the new node

        return newnode