def get_production_rule(G, child, itx):
rhs = nx.Graph()
for n in G.subgraph(child).nodes():
rhs.add_node(n)
for e in G.subgraph(child).edges():
rhs.add_edge(e[0], e[1])
# remove links between external nodes (edges in itx)
for x in itertools.combinations(itx, 2):
if rhs.has_edge(x[0], x[1]):
rhs.remove_edge(x[0], x[1])
return rhs
评论列表
文章目录