本文整理汇总了Python中tree.Node.create_children_tree方法的典型用法代码示例。如果您正苦于以下问题:Python Node.create_children_tree方法的具体用法?Python Node.create_children_tree怎么用?Python Node.create_children_tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.Node
的用法示例。
在下文中一共展示了Node.create_children_tree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_node
# 需要导入模块: from tree import Node [as 别名]
# 或者: from tree.Node import create_children_tree [as 别名]
#.........这里部分代码省略.........
F=E[:] # recopier E
F.remove(x) # enlever x
PGI=generate_posssibilities(p-1,F) # appel recursif
Cx=PGI[:] # recopie du resultat
for A in Cx:
A.append(x)# recombiner avec x tous les elements
R+=Cx # Ajouter les resultats obtenus
return R
key = {}
a = IPv4Address("108.64.77.102",32)
b = IPv4Address("108.96.77.88",32)
key["src_ip"] = a
key["dst_ip"] = b
node1 = NumericalValueNode(key,10,[])
key = {}
c = IPv4Address("108.64.88.102",32)
d = IPv4Address("108.96.88.88",32)
key["src_ip"] = c
key["dst_ip"] = d
node2 = NumericalValueNode(key,20,[])
dict_dim={"src_ip":"ip_addr","dst_ip":"ip_addr"}
common_prefix={"src_ip":a.common_prefix(c),"dst_ip":b.common_prefix(d)}
dim = ["src_ip","dst_ip"]
child = Node.create_children_tree(dim,common_prefix,node1,node2,[node1,node2])
if IPv4Address.IntToDottedIP(common_prefix["src_ip"].get_prefix()) == "108.64.64.0" and common_prefix["src_ip"].get_prefix_len() == 19 and IPv4Address.IntToDottedIP(common_prefix["dst_ip"].get_prefix()) == "108.96.64.0" and common_prefix["dst_ip"].get_prefix_len() == 19:
print "test nodes common_prefix success"
else:
print "test nodes common_prefix ERROR"
if child['src_ip'][0]['dst_ip'][0] == node1 and not 1 in child['src_ip'][0]['dst_ip'].keys() and not 0 in child['src_ip'][1]['dst_ip'].keys() and child['src_ip'][1]['dst_ip'][1] == node2:
print "test nodes create_children success"
else:
print "test nodes create_children ERROR"
key = {}
c = IPv4Address("108.64.77.102",32)
d = IPv4Address("108.96.88.88",32)
key["src_ip"] = c
key["dst_ip"] = d
tt = node1.__class__.__name__
node2 = globals()[tt](key,20,[])
common_prefix={"src_ip":a.common_prefix(c),"dst_ip":b.common_prefix(d)}
dim = ["src_ip","dst_ip"]
child = Node.create_children_tree(dim,common_prefix,node1,node2,[node1,node2])
if IPv4Address.IntToDottedIP(common_prefix["src_ip"].get_prefix()) == "108.64.77.102" and common_prefix["src_ip"].get_prefix_len() == 31 and IPv4Address.IntToDottedIP(common_prefix["dst_ip"].get_prefix()) == "108.96.64.0" and common_prefix["dst_ip"].get_prefix_len() == 19:
print "test nodes common_prefix with artificial split success"