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


Python DirectedHypergraph.get_node_attribute方法代码示例

本文整理汇总了Python中halp.directed_hypergraph.DirectedHypergraph.get_node_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python DirectedHypergraph.get_node_attribute方法的具体用法?Python DirectedHypergraph.get_node_attribute怎么用?Python DirectedHypergraph.get_node_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在halp.directed_hypergraph.DirectedHypergraph的用法示例。


在下文中一共展示了DirectedHypergraph.get_node_attribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_node_attribute

# 需要导入模块: from halp.directed_hypergraph import DirectedHypergraph [as 别名]
# 或者: from halp.directed_hypergraph.DirectedHypergraph import get_node_attribute [as 别名]
def test_get_node_attribute():
    node_a = 'A'
    node_b = 'B'
    node_c = 'C'
    attrib_c = {'alt_name': 1337}
    common_attrib = {'common': True, 'source': False}

    node_list = [node_a, (node_b, {'source': True}), (node_c, attrib_c)]

    # Test adding unadded nodes with various attribute settings
    H = DirectedHypergraph()
    H.add_nodes(node_list, common_attrib)

    assert H.get_node_attribute(node_a, 'common') is True
    assert H.get_node_attribute(node_a, 'source') is False
    assert H.get_node_attribute(node_b, 'common') is True
    assert H.get_node_attribute(node_b, 'source') is True
    assert H.get_node_attribute(node_c, 'alt_name') == 1337

    # Try requesting an invalid node
    try:
        H.get_node_attribute("D", 'common')
        assert False
    except ValueError:
        pass
    except BaseException as e:
        assert False, e

    # Try requesting an invalid attribute
    try:
        H.get_node_attribute(node_a, 'alt_name')
        assert False
    except ValueError:
        pass
    except BaseException as e:
        assert False, e
开发者ID:Murali-group,项目名称:halp,代码行数:38,代码来源:test_directed_hypergraph.py

示例2: main

# 需要导入模块: from halp.directed_hypergraph import DirectedHypergraph [as 别名]
# 或者: from halp.directed_hypergraph.DirectedHypergraph import get_node_attribute [as 别名]
def main():
    #setup the logger
    logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s', filename='C://BPMNexamples/aco.log',level=logging.DEBUG)
    logger = logging.getLogger(__name__)
    
    print(str(sys.getrecursionlimit()))
    sys.setrecursionlimit(100000000)
    print(str(sys.getrecursionlimit()))
    
    
    #file_name = "C://BPMNexamples/inductive/ex1_inductive.pnml"
    #file_name = "C://BPMNexamples/inductive/ex4_inductive.pnml"
    #file_name = "C://BPMNexamples/real_logs/hospital_inductive.pnml"
    #file_name = "C://BPMNexamples/inductive/repair_start_end_inductive.pnml"
    #file_name = "C://BPMNexamples/inductive/ex6_claim_inductive.pnml"
    #The following has loop:
    #file_name = "C://BPMNexamples/inductive/ex5_review_inductive.pnml"
    #file_name = "C://BPMNexamples/alpha/ex1_alpha.pnml"
    
    #MINED WITH INDUCTIVE MINER
    #file_root = "ex1_inductive"
    file_root = "bpi_challenge2012"
    #file_root = "road_fine_process"
    file_type = "inductive"
    
    #MINED WITH ALPHA MINER
    #file_root = "ex6_claim_alpha"
    #file_type = "alpha"
    
    file_name = "C://BPMNexamples/"+file_type+"/"+file_root+".pnml"
    
    tree = ET.parse(file_name)
    pnet = tree.getroot()
    
    hg = DirectedHypergraph()
    #convert pnet into hypergraph
    hg = convert_pnet_to_hypergraph(pnet)
    
    
    #randomly initialise hypergraph
    hg = random_init_attributes(hg)
    print_hg(hg,'hyp.txt')
    
    #find start node (MAKE A FUNCTION FOR IT!!!!)
    nodes = hg.get_node_set()
    start_nodes = []
    for node in nodes:
        if hg.get_node_attribute(node, 'source') == True:
            logger.debug("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
            logger.debug("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
            logger.debug("Found start node: {0}".format(print_node(node, hg)))
            logger.debug("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
            logger.debug("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
            start_nodes.append(node)
    
    #run ACO optimisation
    tau = 0.6
    ANT_NUM = 10
    COL_NUM = 3
    W_UTILITY = {'cost' : 1.0, 'avail' : 0.0, 'qual' : 0.0, 'time' : 0.0}
    
    #call ACO algorithm
    p_opt = aco_algorithm(start_nodes, hg, ANT_NUM, COL_NUM, tau, W_UTILITY)
    
    #highlight on pnet
    show_opt_path_pnet(p_opt, tree, file_root)
    
    #reduce
    reduce_opt_path_pnet(tree, file_root)
开发者ID:emettelatripla,项目名称:HypergraphBPM,代码行数:71,代码来源:aco_pnet.py


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