GrapheneDB Blog

Updates from the GrapheneDB team

Populate Your GrapheneDB Neo4j Instance With a Custom Generated Graph

At GrapheneDB, we are frequently approached by developers working on Neo4j-powered applications, with questions about graph modeling. In this post, we will walk through the process of generating a custom graph with sample data and then populating your GrapheneDB Neo4j instance with it.

If you have data, we usually recommend importing it into Neo4j as outlined in a previous blog post. At that point, you can model the problem, run sample queries and iterate until you get the results you want.

But what if you don’t have any real-world data available? Then generating a sample dataset is probably the best option.

To get started, we recommend Graphgen, a component of the Neoxygen set of tools developed by Christophe Willemsen. It’s a free, open-source, web-based graph generator that you can use to populate Neo4j graphs with sample data. It has following features:

  • A wide range of sample data providers: people’s names, addresses, phone numbers, company names, email addresses, domain names, etc.
  • It relies on a sort of pseudo-Cypher syntax, with the ability to create complex structures
  • and… it’s also capable of populating GrapheneDB instances!

Let’s walk through a detailed example, focusing on people working at companies and the friendship relationship between them.

Step 1: Provision your Neo4j database on GrapheneDB

If you haven’t already, sign up for a free GrapheneDB account at Once logged in, create a new, sandbox database. It’s free!

Creating a Neo4j instance on GrapheneDB

Step 2: Generate the dataset

Sample graph model

Let’s model a simple graph with people and companies:

  • People will be stored as nodes with label Person and a property fullName.
  • Companies will be stored as nodes with label Company and a property name.
  • A Person node can have a KNOWS relationship to other Person nodes
  • Person nodes have a WORKS_AT relationship to a Company

In order to generate this in Graphgen, we will need to describe the pattern in pseudo-Cypher syntax:

(person:Person {name: fullName} *35)-[:WORKS_AT *n..1]->(comp:Company {name: company} *10)
(person)-[:KNOWS *n..n]->(person)

This short snippet will generate:

  • 35 nodes with the Person label and a randomized full name property
  • 10 companies with random company names
  • A relationship WORKS_AT connecting every person to a single random company (n..1)
  • And relationships KNOWS between the Person nodes (many to many, n..n)

Notice the syntax is almost standard Cypher, but with some simple additions to specify properties using formatters, indicate the amount of nodes to create, define the relationships and their cardinality. For further details please read the project documentation.

Next, open, put your code snippet in the text area and hit the Generate button. The resulting dataset will be rendered as an interactive graph which you can navigate.

Generating the graph with Graphgen

Step 3: Populate your GrapheneDB Neo4j instance with the generated dataset

Click on the Populate your database button. A modal dialog will pop up, with fields for the URL, username and password.

Fill out these fields with the connection details located in the Connection tab for your Neo4j instance in the GrapheneDB user interface: URL, username and password.

Populating the database with Graphgen

Step 4: Browse and query your generated dataset on GrapheneDB

Loading the generated graph into your GrapheneDB should take just a few seconds. After the process is completed, go back to GrapheneDB’s interface.

In the overview tab, use the Launch button fire up Neo4j’s web-based browser UI.

Browsing the generated graph in Neo4j

If you, like us, also find Graphgen a useful tool, make sure to say thanks to Christophe for putting it together and stay tuned to his Twitter account for some nice upcoming features.

Graphgen is open-source and you can also have a look at other great Neo4j related tools Christophe put together at, like neoclient, a PHP client for Neo4j which is also supported by GrapheneDB.