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


Python node.Node方法代码示例

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


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

示例1: test_generate_tide_packet

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def test_generate_tide_packet():
    packet_common.add_missing_methods_to_thrift()
    db_tie_info_list = [
        # pylint:disable=bad-whitespace
        # Direction Origin         Type     TieNr SeqNr Lifetime  Allowed in TIDE
        ( SOUTH,     55,           PREFIX,  2,    4,    600),     # No : Non-node S-TIE to S, not self-originated
        ( SOUTH,     MY_SYSTEM_ID, PREFIX,  18,   903,  400)]     # Yes: Non-node S-TIE to S, self-originated
    test_node = make_test_node(db_tie_info_list)
    tide_packet = test_node.generate_tide_packet(
        neighbor_direction=SOUTH,
        neighbor_system_id=55,
        neighbor_level=8,
        neighbor_is_top_of_fabric=False,
        my_level=MY_LEVEL,
        i_am_top_of_fabric=True)
    assert tide_packet.start_range == node.Node.MIN_TIE_ID
    assert tide_packet.end_range == node.Node.MAX_TIE_ID
    assert len(tide_packet.headers) == 1
    expected_header = packet_common.make_tie_header_with_lifetime(SOUTH, MY_SYSTEM_ID, PREFIX, 18, 903, 400)
    assert tide_packet.headers[0] == expected_header 
开发者ID:brunorijsman,项目名称:rift-python,代码行数:22,代码来源:test_node_flood.py

示例2: insert_edge

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def insert_edge(self, parent_id, child_id):
        """
        Insert edge(parent, child) pair into the tree. No assumptions are made about the structure except that a Node
         can have exactly 1 parent, and each child can only occur once. Otherwise; cyclic graphs can be input. This will
         probably cause your layout to run forever.

        :param int parent_id: The id of the parent node.
        :param int child_id: The id of the child node.

        :returns: A tuple of the parent and child nodes as Node objects.
        """
        parent = self.nodes.get(parent_id, Node(parent_id))
        child = self.nodes.get(child_id, Node(child_id))

        child.parent = parent
        parent.children.add(child)

        self.nodes[parent_id] = parent
        self.nodes[child_id] = child

        return parent, child 
开发者ID:buzzfeed,项目名称:pyh3,代码行数:23,代码来源:tree.py

示例3: triples

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def triples(self):
        root = Node(True)
        for node in copy.deepcopy(self.children):
            if node is None:
                continue
            if self._isConnToRoot(node, []) == False and len(self.children[node]) > 0:
                self.add(Node(True), node, ":top")
        lst = self.dfs(root,[])
        if len(self.children[root]) > 1:
            counter = 1
            lst2 = []
            lst2.append(("TOP","",":top","mu","multi-sentence"))
            for v1,c1,l,v2,c2 in lst:
                if v1 == "TOP":
                    v1 = "mu"
                    c1 = "multi-sentence"
                    l = ":snt" + str(counter)
                    counter += 1
                lst2.append((v1,c1,l,v2,c2))
            return lst2
        return lst 
开发者ID:mdtux89,项目名称:amr-eager,代码行数:23,代码来源:relations.py

示例4: names

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def names(name_type, cat, token, var, variables):
    nodes = []
    relations = []
    v1 = variables.nextVar()
    v2 = variables.nextVar()
    ntop = Node(token, v1, cat, False)
    nodes.append(ntop)
    nname = Node(token, v2, "name", False)
    nodes.append(nname)
    relations.append((ntop, nname , ":name"))
    if var in wikis and wikis[var] != "":
        nwiki = Node(token, '"' + wikis[var] + '"', name_type, True)
        if wikis[var] != var:
            nodes.append(nwiki)
    else:
        nwiki = Node(token, '"' + var + '"', name_type, True)
    relations.append((ntop, nwiki , ":wiki"))
    for i, word in enumerate(var.split("_")):
        nop = Node(token, '"' + word + '"', name_type, True)
        nodes.append(nop)
        relations.append((nname, nop , ":op" + str(i + 1)))
    return (nodes, relations) 
开发者ID:mdtux89,项目名称:amr-eager,代码行数:24,代码来源:hooks.py

示例5: _sanitize_response

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def _sanitize_response(self):
        self.sender_id = self._get_id(RESPONSE, ID)
        self.sender_node = Node(self.sender_addr, self.sender_id)
        self.all_nodes = []
        c_nodes = self._get_str(RESPONSE, NODES, optional=True)
        if c_nodes:
            self.nodes = mt.uncompact_nodes(c_nodes)
            self.all_nodes = self.nodes
        try:
            c_nodes2 = self._msg_dict[RESPONSE][NODES2]
        except KeyError:
            self.nodes2 = None
        else:
            self.nodes2 = mt.uncompact_nodes2(c_nodes2)
            for n in self.nodes2:
                if n not in self.all_nodes:
                    self.all_nodes.append(n)

        self.token = self._get_str(RESPONSE, TOKEN, optional=True)
        self.peers = None
        c_peers = self._get_value(RESPONSE, PEERS, optional=True)
        if c_peers:
            self.peers = mt.uncompact_peers(c_peers) 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:25,代码来源:message.py

示例6: uncompact_nodes

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def uncompact_nodes(c_nodes):
    if len(c_nodes) % C_NODE_SIZE != 0:
        logger.info('invalid size (%d) %s' % (len(c_nodes), c_nodes))
        return []
    nodes = []
    for begin in xrange(0, len(c_nodes), C_NODE_SIZE):
        node_id = Id(c_nodes[begin:begin + ID_SIZE_BYTES])
        try:
            node_addr = uncompact_addr(c_nodes[begin + ID_SIZE_BYTES:begin + C_NODE_SIZE])
        except AddrError:
            pass
        else:
            node = Node(node_addr, node_id)
            nodes.append(node)

    return nodes 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:18,代码来源:message_tools.py

示例7: __init__

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def __init__(self, dht_addr, state_path, routing_m_mod, lookup_m_mod, private_dht_name):
        message.private_dht_name = private_dht_name
        self.state_filename = os.path.join(state_path, STATE_FILENAME)
        self.load_state()
        if not self._my_id:
            self._my_id = identifier.RandomId()
        self._my_node = Node(dht_addr, self._my_id)
        self._tracker = tracker.Tracker()
        self._token_m = token_manager.TokenManager()
        self._reactor = ThreadedReactor()
        self._reactor.listen_udp(self._my_node.addr[1], self._on_datagram_received)
        self._querier = Querier(self._my_id)
        bootstrap_nodes = self.loaded_nodes or BOOTSTRAP_NODES
        del self.loaded_nodes
        self._routing_m = routing_m_mod.RoutingManager(self._my_node, bootstrap_nodes)
        self._lookup_m = lookup_m_mod.LookupManager(self._my_id)
        current_time = time.time()
        self._next_maintenance_ts = current_time
        self._next_save_state_ts = current_time + SAVE_STATE_DELAY
        self._running = False 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:22,代码来源:controller.py

示例8: __call__

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def __call__(self, root, *args, **kwargs):
        start_time = timeit.default_timer()
        node = root
        path = []
        while True:
            path.append(node)
            action, condition = self.policies.sample(node)
            if action is not None:
                node.children.append(Node(action=action))
                child = node.children[-1]
                if self.instantiate:
                    node.instantiate(child)
                if self.policies._initialize:
                    self.policies._initialize(child)
                node = child

        elapsed = timeit.default_timer() - start_time
        return elapsed, path 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:20,代码来源:search.py

示例9: GenerateCPJContent

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def GenerateCPJContent(nodelist):
    nodes = nodelist.SlaveNodes.keys()
    nodes.sort()
    
    fileContent = "[TOPOLOGY]\n"
    fileContent += "NetName=%s\n"%nodelist.GetNetworkName()
    fileContent += "Nodes=0x%2.2X\n"%len(nodes)
    
    for nodeid in nodes:
        fileContent += "Node%dPresent=0x01\n"%nodeid
        fileContent += "Node%dName=%s\n"%(nodeid, nodelist.SlaveNodes[nodeid]["Name"])
        fileContent += "Node%dDCFName=%s\n"%(nodeid, nodelist.SlaveNodes[nodeid]["EDS"])
        
    fileContent += "EDSBaseName=eds\n"
    return fileContent

# Function that generates Node from an EDS file 
开发者ID:jgeisler0303,项目名称:CANFestivino,代码行数:19,代码来源:eds_utils.py

示例10: deleteOnIndex

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def deleteOnIndex(self, index: int):
        if self.isEmpty():
            return 
        else:
            lastIndex = self.numberOfElements() - 1
            if index < 0 or index > lastIndex:
                print("Index out of range")
                return
            else:
                if index == 0:
                    self.deleteFromHead()
                elif index == lastIndex:
                    self.deleteFromTail()
                else:
                    prev: Node = None
                    current: Node = self.head
                    count: int = 0
                    while count < index:
                        prev = current
                        current = current.next
                        count += 1
                    prev.next = current.next 
开发者ID:ivanmmarkovic,项目名称:Problem-Solving-with-Algorithms-and-Data-Structures-using-Python,代码行数:24,代码来源:list.py

示例11: sort

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def sort(self):
        if self.isEmpty():
            return
        else:
            swapped: bool = True
            current: Node
            while swapped:
                swapped = False
                current = self.head
                while current != self.tail:
                    if current.key > current.next.key:
                        tmp: int = current.key
                        current.key = current.next.key
                        current.next.key = tmp
                        swapped = True
                    current = current.next 
开发者ID:ivanmmarkovic,项目名称:Problem-Solving-with-Algorithms-and-Data-Structures-using-Python,代码行数:18,代码来源:list.py

示例12: deleteNodesWithValue

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def deleteNodesWithValue(self, value):
        retValue = None
        if self.isEmpty():
            return retValue
        else:
            current: Node = self.head
            while current.next is not None:
                if current.next.key == value:
                    retValue = current.next.key
                    current.next = current.next.next
                    if current.next is not None:
                        current.next.prev = current
                else:
                    current = current.next
            self.tail = current
            if self.head.key == value:
                retValue = self.head.key
                self.deleteFromHead()
            return retValue 
开发者ID:ivanmmarkovic,项目名称:Problem-Solving-with-Algorithms-and-Data-Structures-using-Python,代码行数:21,代码来源:list.py

示例13: deleteNodesWithValue

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def deleteNodesWithValue(self, value):
        if self.isEmpty():
            return
        else:
            current: Node = self.head
            stopped: bool = True
            while current.next != self.head or stopped:
                stopped = False
                if current.next.key == value:
                    current.next = current.next.next
                    current.next.prev = current
                else:
                    current = current.next
            self.tail = current
            self.tail.next = self.head
            self.head.prev = self.tail
            if self.head.key == value:
                self.deleteFromHead() 
开发者ID:ivanmmarkovic,项目名称:Problem-Solving-with-Algorithms-and-Data-Structures-using-Python,代码行数:20,代码来源:list.py

示例14: deleteOnIndex

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def deleteOnIndex(self, index: int):
        if self.isEmpty():
            return 
        else:
            lastIndex = self.numberOfElements() - 1
            if index < 0 or index > lastIndex:
                print("Index out of range")
                return
            else:
                if index == 0:
                    self.deleteFromHead()
                elif index == lastIndex:
                    self.deleteFromTail()
                else:
                    current: Node = self.head
                    count: int = 0
                    while count < index:
                        current = current.next
                        count += 1
                    current.prev.next = current.next
                    current.next.prev = current.prev 
开发者ID:ivanmmarkovic,项目名称:Problem-Solving-with-Algorithms-and-Data-Structures-using-Python,代码行数:23,代码来源:list.py

示例15: insertBefore

# 需要导入模块: import node [as 别名]
# 或者: from node import Node [as 别名]
def insertBefore(self, listElement, newElement):
        if self.isEmpty():
            return
        else:
            current: Node = self.head
            stopped: bool = True
            while current != self.head or stopped:
                stopped = False
                if current.key == listElement:
                    if current == self.head:
                        self.addToHead(newElement)
                    else:
                        newNode = Node(newElement, current.prev, current)
                        newNode.prev.next = newNode
                        newNode.next.prev = newNode
                current = current.next 
开发者ID:ivanmmarkovic,项目名称:Problem-Solving-with-Algorithms-and-Data-Structures-using-Python,代码行数:18,代码来源:list.py


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