Пример #1
0
        targetPro = TargetProvenance(target) ;
        targetPro.read_provenance(prolist) ;
        #print targetPro.prolist ;
        #print targetPro.edgedict ;
        targetProlist.append(targetPro) ; 
    return targetProlist ;

def get_connected_num(targetlist, edge_dict):
    num = 0 ;
    for target in targetlist:
        if( target.if_connected(edge_dict) == True ): num = num + 1 ;
    return num ;

def get_tuple_list(targetlist):
    res = [] ;
    for target in targetlist:
        for edge in target.edgedict.keys(): res.append(edge) ;
    return list(set(res)) ;

if __name__ == "__main__":
    filename = "karate_provenance.txt"
    prolist = open(filename).readlines() ;
    targetlist = get_targets_karate() ;
    for target in targetlist:
        targetPro = TargetProvenance(target) ;
        targetPro.read_provenance(prolist) ;
        print targetPro.prolist ;
        print targetPro.edgedict ;
        print "------------ next target --------------" ;

Пример #2
0
            if( edge_value_dict[edge] == True ): tuple_dict_true[edge] += 1 ;
            for i in range(1, 11):
                temp = int(target_num*i/10.0) ;
                mytuple = (edge, temp) ;
                if( res_effect_list[i-1] == True ):
                    if( edge_value_dict[edge] == True ): flag_dict_true[mytuple] += 1 ;
                    else: flag_dict_false[mytuple] += 1 ;
    mc_num = mc_num * 2 ;    
    res_dict = {} ;
    for edge in tuplelist:
        for i in range(1, 11):
            temp = int(target_num*i/10.0) ;
            mytuple = (edge, temp) ;
            res_dict[mytuple] = flag_dict_true[mytuple]/float(tuple_dict_true[edge]) - flag_dict_false[mytuple]/(mc_num-float(tuple_dict_true[edge])) ;

    return res_dict ;

if __name__ == "__main__":
    filename = "provenance_dataset/karate_provenance.txt";
    targetnodelist = get_targets_karate() ;
    targetlist = readProvenance(filename, targetnodelist) ;

    start = timeit.default_timer() ;
    res_dict = run_mc(targetlist, mc_num=100, k=5) ;
    stop = timeit.default_timer() ;
    print stop-start ;

    lines = get_mc_result_list(res_dict, targetlist, get_tuple_list(targetlist)) ; 
    for line in lines:
        print line ;
Пример #3
0
def causal_test(pro_file_name, mc_num, k):
    targetnodelist = get_targets_karate() ;
    targetlist = readProvenance(filename, targetnodelist) ;
    res_dict = run_mc(targetlist, mc_num, k) ;
    return get_mc_result_list(res_dict, targetlist, get_tuple_list(targetlist)) ;