cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Graph Generators similar to NetworkX

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)

2 REPLIES 2

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()

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!

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online