Ejemplo n.º 1
0
def newDPA(n, m):
    '''
    DPA Algorithm to generate random directed graphs
    :param n: number of nodes
    :param m: integer (1 <= m <= n)
    :return:A directed graph
    '''
    gE = graph_util.make_complete_graph(m)
    dpat = dh.DPATrial(m)
    for i in range(m, n):
        # V1 = select_random_nodes(gE, m, indeg, totindeg)
        V1 = dpat.run_trial(m)
        gE[i] = set(V1)
    return gE
Ejemplo n.º 2
0
def generate_UPA(n, m):
    '''
    UPA Algorithm to generate random undirected graphs
    :param n: number of nodes
    :param m: integer (1 <= m <= n)
    :return:A directed graph
    '''
    gE = graph_util.make_complete_graph(m)
    dpat = uh.UPATrial(m)
    for i in range(m, n):
        # V1 = select_random_nodes(gE, m, indeg, totindeg)
        V1 = dpat.run_trial(m)
        gE[i] = set(V1)
        for neighbour in V1:
            gE[neighbour].add(i)
    return gE
Ejemplo n.º 3
0
def DPA(n, m):
    '''
    DPA Algorithm to generate random directed graphs
    :param n: number of nodes
    :param m: integer (1 <= m <= n)
    :return:A directed graph
    '''
    gE = graph_util.make_complete_graph(m)
    indeg = graph_util.compute_in_degrees(gE)
    totindeg = totalindeg(indeg)
    for i in range(m, n):
        V1 = select_random_nodes(gE, m, indeg, totindeg)
        gE[i] = set(V1)
        for j in V1:
            indeg[j] = indeg[j] + 1
        indeg[i] = 0
        totindeg = totindeg + len(V1)
    return gE