当前位置: 首页>>代码示例>>Python>>正文


Python Node.Node方法代码示例

本文整理汇总了Python中Node.Node方法的典型用法代码示例。如果您正苦于以下问题:Python Node.Node方法的具体用法?Python Node.Node怎么用?Python Node.Node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node的用法示例。


在下文中一共展示了Node.Node方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initialize

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def initialize():
    """This function initializes the application"""

    #Gather information about the current device and display it
    thisNode = Node(fetch_IP_address(), fetch_MAC_address(), fetch_broadcast_address(), scanHosts())
    print("My IP is {} and MAC is {}\n".format(thisNode.getIPAddress, thisNode.getMACAddress))

    #Register this device as a listener for incoming messages
    listener = Listener(thisNode)

    #Election of a master node
    begin_election_process(thisNode, listener)

    #Initialises threads for scanning devices and messaging
    scanner_thread = threading.Thread(target=network_scanner, args=(thisNode,listener))
    listener_thread = threading.Thread(target=network_listener, args=(listener,))

    #start scanning and listener threads
    scanner_thread.start()
    listener_thread.start() 
开发者ID:mcvavy,项目名称:pyNet,代码行数:22,代码来源:start.py

示例2: SelectNodeColor

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def SelectNodeColor(self,state):
        nodes1 = [item for item in self.scene().items() if isinstance(item, Node)]
        if state == "Correlation Strength": 
            self.ColorNodesBasedOnCorrelation = True 
            for node in nodes1:
                node.NodeColor()
            self.Tab_2_CorrelationTable().hide()
            self.CommunityMode.emit(False)
        else: 
            self.ColorNodesBasedOnCorrelation = False 
            if not(self.level == -1):
                self.communityDetectionEngine.ChangeCommunityColor(self.level)
            else: 
                self.communityDetectionEngine.ChangeCommunityColor()
            self.CommunityMode.emit(True)
            self.CommunityColor.emit(self.ColorToBeSentToVisit)
        self.Scene_to_be_updated.update()
        del nodes1 
开发者ID:sugeerth,项目名称:ECoG-ClusterFlow,代码行数:20,代码来源:Graph_interface.py

示例3: insert

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def insert(self, key, data):
        """
        Insert new key into node
        """
        # Create new node
        n = Node(key, data)

        # Initial tree
        if not self.node:
            self.node = n
            self.node.left = AVLTree()
            self.node.right = AVLTree()
        # Insert key to the left subtree
        elif key < self.node.key:
            self.node.left.insert(key, data)
        # Insert key to the right subtree
        elif key > self.node.key:
            self.node.right.insert(key, data)

        # Rebalance tree if needed
        self.rebalance() 
开发者ID:amrelarabi,项目名称:spell-checker-with-python-3,代码行数:23,代码来源:AVLTree.py

示例4: insertAtFront

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def insertAtFront(self,data):
        newNode = Node()
        newNode.setData(data)
        newNode.setNext(newNode)
        if self.length==0:
            self.head = newNode
            newNode.setNext(self.head)
            self.length += 1
        else:
            tempNode = self.head
            while tempNode.getNext() != self.head:
                tempNode = tempNode.getNext()
            tempNode.setNext(newNode)
            newNode.setNext(self.head)
            self.head = newNode
            self.length+=1 
开发者ID:ridwanrahman,项目名称:datastructures,代码行数:18,代码来源:circularLinkedList.py

示例5: network_scanner

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def network_scanner(thisNode, listener):
    '''Thread to forever loop scanning the network'''
    while True:
        try:
            print("Scanning for new hosts............\n")
            newHostScans = scanHosts()
        except subprocess.CalledProcessError as e:
            print('nmam error')
            time.sleep(60*5)
            continue



        """ Looping through the newly scanned hosts"""
        #Check if each host in the new list is in our current list
        for host in newHostScans:
            if host not in thisNode.getCurrentHosts:
                thisNode.add_node(host)

        """Ping all addresses on our list to check if they are alive or dead"""
        for host in thisNode.getCurrentHosts:
            if command_executor(host[0]) == '':
                thisNode.remove_node(host)

        '''Check if master is alive/dead then raise election requests'''
        if not thisNode.getMasterNode:
            begin_election_process(thisNode, listener)
        else:
            if command_executor(thisNode.getMasterNode[0]) == '':
            #We kickoff election contest
                begin_election_process(thisNode, listener)

        if command_executor(thisNode.getIPAddress) == '':
            thisNode.update_ip_address(fetch_IP_address())
            begin_election_process(thisNode, listener)

        time.sleep(5)

        if thisNode.getMasterNode:
            print("Current Master is Node with IP: {} ,  MAC: {}, Vendor: {}\n\n".format(thisNode.getMasterNode[0],thisNode.getMasterNode[1],thisNode.getMasterNode[2]))
        print("Current live hosts are {}\n\n".format(thisNode.getCurrentHosts)) 
开发者ID:mcvavy,项目名称:pyNet,代码行数:43,代码来源:start.py

示例6: create_mynode

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def create_mynode():
    import Node

    my_ip = get_node_ip()

    new_node = Node.Node(my_ip)

    mynode_jobj = {
        'type': new_node.type,
        'ip_address': new_node.ip_address
    }

    j_str = json.dumps(mynode_jobj)

    return mynode_jobj, j_str 
开发者ID:JoohyeongSong,项目名称:EV3-Project,代码行数:17,代码来源:NodeController.py

示例7: bstInsert

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def bstInsert(self, subtree, key, value):
        if subtree is None:
            subtree = Node(key, value)
        elif key < subtree.key:
            subtree.left = self.bstInsert(subtree.left, key, value)
        elif key > subtree.key :
            subtree.right = self.bstInsert(subtree.right, key, value)
        return subtree

    # Removes the node associated with the given key. 
开发者ID:amrelarabi,项目名称:spell-checker-with-python-3,代码行数:12,代码来源:BinarySearchTree.py

示例8: insertAtBeginning

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def insertAtBeginning(self, data):
        newNode = Node(data)
        if (self.head == None):
            self.head = self.tail = newNode
            self.length += 1
        else:
            newNode.setPrev(None)
            newNode.setNext(self.head)
            self.head.setPrev(newNode)
            self.head = newNode
            self.length += 1 
开发者ID:ridwanrahman,项目名称:datastructures,代码行数:13,代码来源:doublyLinkedList.py

示例9: insertAtEnd

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def insertAtEnd(self, data):
        currentNode = self.head
        newNode = Node(data)
        if (self.head == None):
            self.head = newNode
            self.tail = self.head
        else:
            while currentNode.getNext()!=None:
                currentNode = currentNode.getNext()
            currentNode.setNext(newNode)
            newNode.setPrev(currentNode)
            newNode.setNext(None) 
开发者ID:ridwanrahman,项目名称:datastructures,代码行数:14,代码来源:doublyLinkedList.py

示例10: insertAtPos

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def insertAtPos(self, data, pos):
        newNode = Node(data)
        if self.head == None or pos == 0:
            self.insertAtBeginning(data)
        else:
            tempNode = self.getNode(pos)
            newNode.setPrev(tempNode.getPrev())
            tempNode.getPrev().setNext(newNode)
            newNode.setNext(tempNode)
            tempNode.setPrev(newNode)
            self.length += 1 
开发者ID:ridwanrahman,项目名称:datastructures,代码行数:13,代码来源:doublyLinkedList.py

示例11: insertAtEnd

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def insertAtEnd(self, data):
        newNode = Node()
        newNode.setData(data)
        newNode.setNext(newNode)
        if self.length==0:
            self.head = newNode
            newNode.setNext(self.head)
            self.length += 1
        else:
            currentNode = self.head
            newNode.setNext(self.head)
            while currentNode.getNext()!=self.head:
                currentNode = currentNode.getNext()
            currentNode.setNext(newNode)
            self.length+=1 
开发者ID:ridwanrahman,项目名称:datastructures,代码行数:17,代码来源:circularLinkedList.py

示例12: push

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def push(self,data):
        newNode = Node()
        newNode.setData(data)
        if self.length == 0:
            newNode.setNext(self.head)
            self.head = newNode
            self.temp_first_node = newNode
            self.length += 1
        else:
            newNode.setNext(self.head)
            self.head = newNode
            self.length +=1 
开发者ID:ridwanrahman,项目名称:datastructures,代码行数:14,代码来源:Stack.py

示例13: insert

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def insert(self, data):
        # if we are inserting a node for the first time
        if not self.rootNode:
            self.rootNode = Node(data)
        else:
            self.rootNode.insertRecursive(data)

    # method to remove a node 
开发者ID:pranavj1001,项目名称:LearnLanguages,代码行数:10,代码来源:BinarySearchTree.py

示例14: remove

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def remove(self, dataToRemove):
        # check if the tree is empty or not
        if self.rootNode:
            # if we have to remove the root node
            if self.rootNode.data == dataToRemove:
                # create a new node
                tempNode = Node(None)
                # make its leftChild the rootNode
                tempNode.leftChild = self.rootNode
                # then continue with the remove process
                self.rootNode.removeRecursive(dataToRemove, tempNode)
            else:
                self.rootNode.removeRecursive(dataToRemove, None)

    # method to display the max node of the tree 
开发者ID:pranavj1001,项目名称:LearnLanguages,代码行数:17,代码来源:BinarySearchTree.py

示例15: putItem

# 需要导入模块: import Node [as 别名]
# 或者: from Node import Node [as 别名]
def putItem(self, node, key, value, index):

        # get the character from the key
        # initially index is zero i.e. get the first char initially
        character = key[index]

        # if there's no node for the current character then create a new node
        if node is None:
            node = Node(character)

        # if the character has a lesser value than the current node then go left
        if character < node.char:
            node.leftNode = self.putItem(node.leftNode, key, value, index)

        # if the character has a greater value than the current node then go right
        elif character > node.char:
            node.rightNode = self.putItem(node.rightNode, key, value, index)

        # when the above two conditions are false
        # and we have not traversed through the entire characters of the key
        # then go middle
        elif index < len(key) - 1:
            node.middleNode = self.putItem(node.middleNode, key, value, index + 1)

        # insert the value here as we have traversed through the characters of the key
        else:
            node.value = value

        return node

    # function to get the value from the key 
开发者ID:pranavj1001,项目名称:LearnLanguages,代码行数:33,代码来源:TST.py


注:本文中的Node.Node方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。