本文整理汇总了Python中networkx.DiGraph.node[nd]['sat']方法的典型用法代码示例。如果您正苦于以下问题:Python DiGraph.node[nd]['sat']方法的具体用法?Python DiGraph.node[nd]['sat']怎么用?Python DiGraph.node[nd]['sat']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkx.DiGraph
的用法示例。
在下文中一共展示了DiGraph.node[nd]['sat']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ts_from_expr
# 需要导入模块: from networkx import DiGraph [as 别名]
# 或者: from networkx.DiGraph import node[nd]['sat'] [as 别名]
def ts_from_expr(symtab, exprtab):
"""
symtab and exprtab are as produced by form.util.gen_expr().
"""
envtrans = dict()
systrans = list()
num_uncontrolled = len([i for i in range(len(symtab)) if symtab[i]['uncontrolled']])
identifiers = [v['name'] for v in symtab]
next_identifiers = [v['name']+'_next' for v in symtab]
evalglobals = {'__builtins__': None, 'True': True, 'False': False}
envtrans_formula = '(' + ') and ('.join(exprtab['ENVTRANS']) + ')'
for state in stategen(symtab):
stated = dict(zip(identifiers, state))
envtrans[state] = []
for next_state in stategen([v for v in symtab if v['uncontrolled']]):
stated.update(dict(zip(next_identifiers, next_state)))
if eval(envtrans_formula, evalglobals, stated):
envtrans[state].append(next_state)
systrans_formula = '(' + ') and ('.join(exprtab['SYSTRANS']) + ')'
for state in stategen(symtab):
stated = dict(zip(identifiers, state))
for next_state in stategen(symtab):
stated.update(dict(zip(next_identifiers, next_state)))
if eval(systrans_formula, evalglobals, stated):
systrans.append((state, next_state))
G = DiGraph()
G.add_edges_from(systrans)
for nd in G.nodes_iter():
G.node[nd]['sat'] = list()
stated = dict(zip(identifiers, nd))
for subformula in ['ENVINIT', 'SYSINIT']:
if eval(exprtab[subformula], evalglobals, stated):
G.node[nd]['sat'].append(subformula)
for subformula in ['ENVGOAL', 'SYSGOAL']:
for (i, goalexpr) in enumerate(exprtab[subformula]):
if eval(goalexpr, evalglobals, stated):
G.node[nd]['sat'].append(subformula+str(i))
return AnnTransitionSystem(symtab, G, envtrans,
num_egoals=len(exprtab['ENVGOAL']),
num_sgoals=len(exprtab['SYSGOAL']))