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


Python DiGraph.node[nd]['sat']方法代码示例

本文整理汇总了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']))
开发者ID:slivingston,项目名称:gr1py,代码行数:49,代码来源:tstruct.py


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