Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-31-2019 07:31 AM
I am trying to create some test data including a sample social network. In NetworkX, there are several generators to create different types of graph structures. Are there any similar algorithms for neo4j?
For example:
G= nx.dorogovtsev_goltsev_mendes_graph(4,create_using=None)
12-04-2019 02:23 PM
Sorry for the late, like 10 months late reply. But someone just asked me this same question, which led me to this post, which for completeness is an easy one to answer. There are generators in apoc library. Or, you could just use the functions in networkx to create a list of edge node id's and build the vertices (relationships) between them in your code and fill in your own details (e.g. properties). Might also be interested in the ' A NetworkX-esque API for Neo4j Graph Algorithms' effort.
# generate ba graph
import networkx as nx
import matplotlib.pyplot as plt
%matplotlib inline
ba = nx.barabasi_albert_graph(500,7)
# Display graph and convert data into data frame
import pandas as pd
plt.axes([0.2, 0.2, 0.7, 0.7])
Gcc = sorted(nx.connected_component_subgraphs(ba), key=len, reverse=True)[0]
pos = nx.spring_layout(Gcc)
plt.axis('off')
nx.draw_networkx_nodes(Gcc, pos, node_size=10)
nx.draw_networkx_edges(Gcc, pos, alpha=0.2)
# get source and target node id's
df=nx.to_pandas_edgelist(ba)
df.head()
12-10-2019 02:03 AM
Even better, we added a function for random graph generation about a month ago: https://neo4j.com/docs/graph-algorithms/current/labs-algorithms/graph-generation/
The new function will let you quickly create graphs, within neo4j, with a specified size and degree distribution.
Please give it a try!
All the sessions of the conference are now available online