本文整理汇总了Python中group.Group.try_to_convert方法的典型用法代码示例。如果您正苦于以下问题:Python Group.try_to_convert方法的具体用法?Python Group.try_to_convert怎么用?Python Group.try_to_convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类group.Group
的用法示例。
在下文中一共展示了Group.try_to_convert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: aggregate_group
# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import try_to_convert [as 别名]
def aggregate_group(self, group, group_name = None):
if type(group) == list:
g = Group(self.workflow, name=group_name)
g.add_nodes(group)
elif type(group) == Group:
g = group
else:
raise Exception, "Type of group should be %s or %s!" % (type(Group), list)
G = self.connection_graph
new_edges = list()
for s in G.edges:
for e in G.edges[s]:
for v in G.edges[s][e]:
edge = G.edges[s][e][v]
s_in_group = s in g.nodes
e_in_group = e in g.nodes
if not s_in_group and e_in_group:
new_edges.append((s, edge["from_port"],
g.name, g.get_group_port_name(s, edge["from_port"], "from")))
elif s_in_group and not e_in_group:
new_edges.append((g.name, g.get_group_port_name(e, edge["to_port"], "to"),
e, edge["to_port"]))
else:
continue
map(lambda (s, sp, e, ep): G.add_edge(s, sp, e, ep), new_edges)
G.remove_nodes_from(g.nodes)
# GenericComposite will have the same name as Group g
G.node[g.name] = g.try_to_convert()
return self