예제 #1
0
def app_q5():
    # get the data into a dict
    data1 = project.dpa_graph(27770, 13)
    data = utils.read_graph_data("alg_phys-cite.txt")

    draw_plot(data, "r+", "citations")
    draw_plot(data1, "gs", "dpa_graph(27770,13)")
    plt.show()
예제 #2
0
def app_q2():
    data3 = project.generate_random_digraph(500, .25)
    data2 = project.generate_random_digraph(700, .55)
    data1 = project.generate_random_digraph(1000, .9)
    data = utils.read_graph_data("alg_phys-cite.txt")

    draw_plot(data, "r+", "citations")
    draw_plot(data3, "g^", "random_graph(500, .25)")
    draw_plot(data2, "ys", "random_graph(700, .55)")
    draw_plot(data1, "mo", "random_graph(1000, .9)")
    plt.show()
예제 #3
0
def app_q3():
    # get the data into a dict
    data = utils.read_graph_data("alg_phys-cite.txt")
    out_degrees = project.compute_out_degrees(data)
    in_degrees = project.compute_in_degrees(data)

    num_nodes = len(data.keys())
    total_in_degrees = sum(in_degrees.values())
    total_out_degrees = sum(out_degrees.values())
    print "num nodes: ", str(num_nodes)
    print "total out degree: " + str(total_out_degrees)
    print "total in degree: " + str(total_in_degrees)
    print "average out-degree of citations: " + str(float(total_out_degrees) / num_nodes)
    print "average in-degree of citations: " + str(float(total_in_degrees) / num_nodes)
예제 #4
0
            attack_order.append(u)

            provided.delete_node(graph, u)

    return attack_order

# import graph_data as gd
# print fast_targeted_order(gd.GRAPH2)
# quit()

"""
generate graph data for use in the questions
"""
# get the network graph
net_g = utils.read_graph_data("alg_rf7.txt")

# generate a upa graph with the given average out-degree
total_out_degrees = sum(m1project.compute_out_degrees(net_g).values())
average_degree = float(total_out_degrees) / len(net_g) / 2
m = int(round(average_degree))
upa_g = upa_graph(len(net_g), m)

# create an ER ugraph
network_size = len(net_g)
total_possible_edges = (network_size * (network_size - 1)) / 2
p = total_out_degrees / float(total_possible_edges) / 2
er_g = generate_random_ugraph(len(net_g), p)

# utils.print_graph_data(net_g, name="net_g")
# utils.print_graph_data(upa_g, name="upa_g")
예제 #5
0
def app_q1():
    # get the data into a dict
    data = utils.read_graph_data("alg_phys-cite.txt")

    draw_plot(data, "r+", "citations")
    plt.show()