Example #1
0
def data_analysis(data, out, count, analysis):

    
    DAG = arXiv.arXivDAG(data) #full box is a list with first entry the new boxDAG and second entry a list containg the two extremal points

    path_ends = ['0302182', '0012251']
        
    out.write('\n' + 'The start node is %s and the end node is %s' %(path_ends[0], path_ends[1]))
        
    # Do J^2 testing
    #start_time = time.clock()
    #jsquared_algorithm(DAG, path_ends, out, count)
    #jsquared_time = time.clock() - start_time
    #print 'J^2 time = %s' % jsquared_time
    
    # Do J^2 testing with birthday
    #start_time = time.clock()
    #lp.jsquared_with_birthdays(DAG, path_ends, out, count)
    #jsquared_with_birthdays_time = time.clock() - start_time
    #print 'J^2 with birthdays time = %s' % jsquared_with_birthdays_time
        
    # Do Tim algorithm
    #start_time = time.clock()
    #lp.tim_algorithm(DAG, path_ends, out, count)
    #tim_time = time.clock() - start_time
    #print 'Tim time = %s' % tim_time
    
    
    # Do Tim algorithm with order
    start_time = time.clock()
    lp.tim_algorithm_with_ordered_search(DAG, path_ends, out, count)
    tim_with_order_time = time.clock() - start_time
    print 'Tim with order time = %s' % tim_with_order_time
    
    # Do Tim algorithm with order and birthday
    start_time = time.clock()
    lp.tim_algorithm_with_ordered_search_and_birthdays(DAG, path_ends, out, count)
    tim_with_birthdays_time = time.clock() - start_time
    print 'Tim with birthdays time = %s' % tim_with_birthdays_time
    
    analysis.write(str(DAG.number_of_edges()) + '\n')
        if isinstance(path, list): #if 'path' is a list of lists, carry out the process again to check the composition of THOSE lists
            make_list_of_paths(path, pathlist)
    return pathlist #Return a list that just contains paths (in list form) of nodes (no lists of lists of lists of...)
    
if __name__ == "__main__": 
    out = open(outfile,'w') #output file  
    count = open(countfile,'a+') #output file
    data = open('C:\Users\Jamie\Project\CitNet.DAT', 'r') #input data
    analysis = open(analysisfile, 'w') #analysis file
    
    #n_list = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]
    #n_list = [50, 75, 100, 125, 150, 175, 200, 225, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1100, 1200, 1300, 1400, 1500]
    #n_list = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
    #n_list = [10, 10, 10, 20, 30, 30]
    
    DAG = arXiv.arXivDAG(data)
    print 'DAG construction complete'
    start_time = time.clock()
    TR_DAG = TR_from_examining_edges(DAG)
    print 'There are %d edges in the original DAG' %DAG.number_of_edges()
    print 'There are %d edges in the TR DAG' %TR_DAG.number_of_edges()
    total_time = time.clock() - start_time  
    print 'TR complete in %f' %total_time    
    
    '''for N in n_list:
        start_time = time.clock()
        DAG_and_corners = boxmaker.box_generator_corners(N, 2)
        DAG = DAG_and_corners[0]

        #out.write('\n' + 'The edges in the original DAG:')
        #for edge in DAG.edges():