initIntervals.append((0, 10))
 
 
 tic = time.time()
 #avg_greedy, _, num_nodes_gr = main.main(outpath, 'greedy', charikar_version, 'unweighted', pics, k, B, edgesTS, nodes, edges, initIntervals, False)
 nodes_coveredGr, timeIntGr, usedBgr, S, edges_coveredGr = main.main(outpath, 'greedy', charikar_version, 'unweighted', pics, k, B, edgesTS, nodes, edges, initIntervals, False)
 usedBgr = usedBgr.total_seconds()/(60*60*24.0)  
 
 #avg_greedy = 2.0*S.number_of_edges()/S.number_of_nodes()
 avg_greedy = 2.0*len(edges_coveredGr)/len(nodes_coveredGr)
 num_nodes_gr = len(nodes_coveredGr)
 num_edges_gr = len(edges_coveredGr)
 toc = time.time()
 print 'greedy done in: ', toc-tic
 
 minspanGr, st, end = utils.shortestInt(edgesTS, edges_coveredGr);
 minspanGr = minspanGr.total_seconds()/(60*60*24.0)
 
 sys.stdout.flush()
 
 tic = time.time()
 #avg_binary, _, num_nodes_bi = main.main(outpath, 'binary', charikar_version, 'unweighted', pics, k, B, edgesTS, nodes, edges, initIntervals, False)
 nodes_coveredBi, timeIntBi, usedBbi, S, edges_coveredBi = main.main(outpath, 'binary', charikar_version, 'unweighted', pics, k, B, edgesTS, nodes, edges, initIntervals, False)
 usedBbi = usedBbi.total_seconds()/(60*60*24.0)
 
 avg_binary = 2.0*len(edges_coveredBi)/len(nodes_coveredBi)
 num_nodes_bi = len(nodes_coveredBi)
 num_edges_bi = len(edges_coveredBi)
 toc = time.time()
 print 'binary done in: ', toc-tic
 minspanBi, st, end  = utils.shortestInt(edgesTS, edges_coveredBi)
Esempio n. 2
0
initIntervals = [(0, len(edgesTS) - 1)]

edgesTSBi = copy.deepcopy(edgesTS)
edgesTSGr = copy.deepcopy(edgesTS)
G = utils.getGraph(edgesTS)

for ind in xrange(0, comN):

    try:
        S, avg_char = charikar.charikar(copy.deepcopy(G))
        G.remove_edges_from(S.edges())
        Sedges = S.edges()
        Sedges = np.array(S.edges())
        Sedges.sort(1)
        Sedges = map(tuple, Sedges)
        minspanChar, _, _ = utils.shortestInt(edgesTS, Sedges)
        minspanChar = minspanChar.total_seconds() / (60 * 60 * 24.0)
    except:
        print S.number_of_nodes()
        minspanChar = -1
        avg_char = -1

    if runMainAlgs == 'grbi':

        #avg_greedy, _, num_nodes_gr = main.main(outpath, 'greedy', charikar_version, 'unweighted', pics, k, B, edgesTS, nodes, edges, initIntervals, False)
        #nodes_coveredGr, timeIntGr, usedBgr, S, edges_coveredGr = loop_and_short_function.gamble(edgesTSGr, k, B, n, 'gr', nodes, edges, [(0,len(edgesTSGr)-1)])
        nodes_coveredGr, timeIntGr, usedBgr, Sgr, edges_coveredGr = main.main(
            outpath, 'greedy', charikar_version, 'unweighted', pics, k, B,
            edgesTSGr, nodes, edges, [(0, len(edgesTSGr) - 1)], False)
        #print edges_coveredGr
        usedBgr = usedBgr.total_seconds() / (60 * 60 * 24.0)