Exemple #1
0
def analsys_graph(G):
    #print("Drawing the graph")
    #helpers.draw_graph(G)
    print("analysing the graph")
    print("Nodes: ", G.number_of_nodes())
    print("Edges: ", G.number_of_edges())
    # Draw loglog graph...
    #DG = G.to_directed()
    print("Drawing the loglog graph")
    helpers.plot_degseq(G, False)
    print('')
Exemple #2
0
def analyse_directed_graph():
    graph = load_graph('college', True)
    # helpers.draw_graph(graph)
    #print("Graph nodes: ", graph.number_of_nodes())
    #print("Graph edges: ", graph.number_of_edges())  # already has edges from dataset...
    print(nx.info(graph))

    analyse_strongly_connected_components(graph)

    # Draw loglog graph...
    helpers.plot_degseq(graph, False)

    # wait at end...
    input("Press Enter to Continue ...")
Exemple #3
0
def main():

    graph = load_graph("facebook")
    helpers.plot_degseq(graph, False)
    num_nodes = graph.number_of_nodes()

    x = [random.random() for i in range(num_nodes)]
    y = [random.random() for i in range(num_nodes)]

    x = np.array(x)
    y = np.array(y)

    pos = dict()
    for i in range(num_nodes):
        pos[i] = x[i], y[i]

    print("Graph nodes: ", graph.number_of_nodes())
    print("Graph edges: ",
          graph.number_of_edges())  # already has edges from dataset...
    print("Pos nodes: ", len(pos))

    # plot the graph...
    A = nx.adjacency_matrix(graph)
    graph = nx.Graph(A)
    print("Graph nodes after rebuild: ", graph.number_of_nodes())
    print("Graph edges after rebuild: ",
          graph.number_of_edges())  # already has edges from dataset...
    # Plot the nodes only
    plot_graph(graph, pos, 1, False)
    # plot the nodes and edges
    plot_graph(graph, pos, 2)

    # reposition with the eigenvectors
    eigenv_pos, V = repos_with_eigs(A, num_nodes)
    plot_graph(graph, eigenv_pos, 3)

    print("Plotting spring layout")
    pos = nx.spring_layout(graph)
    plot_graph(graph, pos, 4)

    # Look at the clustering
    features = np.column_stack((V[:, 1], V[:, 2]))
    cluster_nodes_from_original_example(graph, features, pos, eigenv_pos)

    # Finally, use the columns of A directly for clustering
    # cluster_nodes_from_original_example(graph, A.todense(), pos, eigenv_pos)

    # wait at end...
    input("Press Enter to Continue ...")
Exemple #4
0
def run_price_model_sim():
    full_graph = create_price_model_graph()

    print_price_model_graph_as_text(full_graph)
    helpers.plot_degseq(full_graph, False)
    input("Press enter to finish.")