# Graph Generators similar to NetworkX

**URL:** <https://community.neo4j.com/t/graph-generators-similar-to-networkx/4765>\
**Category:** Procedures & APOC\
**Tags:** networkx\
**Created:** [January 31, 2019, 3:31pm UTC](https://community.neo4j.com/t/graph-generators-similar-to-networkx/4765 "2019-01-31T15:31:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikehancock72](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mikehancock72/32/286_2.png) [@mikehancock72](https://community.neo4j.com/u/mikehancock72)\
**Post date:** [January 31, 2019, 3:31pm UTC](https://community.neo4j.com/t/graph-generators-similar-to-networkx/4765/1 "2019-01-31T15:31:34Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![dan.flavin](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dan.flavin/32/4441_2.png) [@dan.flavin](https://community.neo4j.com/u/dan.flavin)\
**Post date:** [December 4, 2019, 10:23pm UTC](https://community.neo4j.com/t/graph-generators-similar-to-networkx/4765/2 "2019-12-04T22:23:06Z")

</div>

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](https://neo4j.com/docs/labs/apoc/current/graph-updates/graph-generators/#graph-generators) 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'](https://medium.com/neo4j/experimental-a-networkx-esque-api-for-neo4j-graph-algorithms-4002baac45be) effort.

```auto
# 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()

```

 ![image](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/2X/7/7ab2b3cff9a7302352dfa25b64f58516bb174d0e.jpeg)

---

<div class="post-metadata">

**Author:** ![alicia.frame](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/alicia.frame/32/4507_2.png) [@alicia.frame](https://community.neo4j.com/u/alicia.frame)\
**Post date:** [December 10, 2019, 10:03am UTC](https://community.neo4j.com/t/graph-generators-similar-to-networkx/4765/3 "2019-12-10T10:03:27Z")

</div>

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/](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!
