コード例 #1
0
def getErdosRenyiGraph(n, k, directed = False, weighted = False, connected = True):
    if not connected:
        return random_graphs.getRandomGraphs(1, n, k, directed = directed, weighted = weighted)[0]
    gr = graph.graph.graph(directed = directed, weighted = weighted)
    while True:
        el = random_graphs.getRandomGraphs(1, n, k, directed = directed, weighted = weighted)[0]
        gr.create(el, n)
        if not algorithms.connectivity.connectivity.isGraphConnected(gr):
            gr.reset()
            continue
        return el
コード例 #2
0
def getSeedGraphs(num, params):
    # Need to remove the hardcoded '7'. Could have more or less params.
    # Also, better validation needs to be done for the params.
    params = params.split()
    if len(params) < 7:
        return None
    directed = False
    if params[0] == '1':
        directed = True
    n = int(params[1])
    p = int(params[2])
    epn = int(params[3])
    k = int(params[4])
    alpha = float(params[5])
    weighted = False
    if params[6] == 'w':
        weighted = True
    seedgraphs = None
    seedgraphs = random_graphs.getRandomGraphs(num, n, k, p, epn, -1, directed, weighted)
    #seedgraphs = random_graphs.getRandomGraphs(num, n, k)
    #if not directed:
    #seedgraphs = random_graphs.getRandomGraphs(int(num * 0.99), n, k, p, epn, -1, directed, weighted)
    #specialseeds = random_graphs.getRandomGraphs(int(num * 0.01), n, k, p, epn, alpha, directed, weighted)
    #seedgraphs.extend(specialseeds)
    #print 'initialized'
    #seedgraphs = random_graphs.getRandomGraphs(num, n, k, p, epn, alpha, directed, weighted)
    #else:
    #    seedgraphs = random_graphs.getRandomGraphs(num, n, k, p, epn, -1, directed, weighted)    
    return seedgraphs
コード例 #3
0
def computeBestAcon(argv):
    n = int(argv[1])
    rgs = random_graphs.getRandomGraphs(1000, n, n - 1)
    tcosts = computeTransitionCosts(rgs, n)
    for tcost in tcosts:
        print tcost
    print len(tcosts)
    return