10. Getting started with Neo4j and Gephi Tool

Nihar javiya
4 min readSep 20, 2021

Neo4j stores and manages data in its more natural, connected state, maintaining data relationships that deliver lightning-fast queries, deeper context for analytics, and a pain-free modifiable data model.

In a simple word, Neo4j is the MySQL of the graph databases. It provides a graph database management system, a language to query the database, a.k.a CYPHER, and a visual interface with the neo4j browser.

Let’s start the demo,

  1. Download neo4j Desktop, and install it
  2. After the installation
CREATE (databse:Database{name:"Neo4j"})-[r:SAYS]->(message:Message{name:"Hello World"})
RETURN databse,message,r

You can see that the 2 nodes is created and one relation called says is created using the query.

Here I have used Movies database for demo purpose only, you can create by yourself just by clicking Create new. Start the Movies database and see the database in the Neo4j browser.

After that load the movie database to the neo4j and it will show the data in graph format.

use below command to find total nodes.

MATCH (n) RETURN count(n)
//find labels in database
CALL db.labels()
// Find types of relationship between tables
CALL db.relationshipTypes()

By using this query we can know that how the person is connected to the movie,who is producer of movie, which role person acted in the movie.

// query for the movies released in 1990s
MATCH (nineties:Movie) WHERE nineties.released >= 1990 AND nineties.released < 2000 RETURN nineties.title
//query for list all tom hanks movie
MATCH (tom:Person {name: "Tom Hanks"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom,tomHanksMovies

Gephi Tool

Gephi is an open-source network analysis and visualization software package. It is mainly used for visualizing, manipulating, and exploring networks and graphs from raw edge and node graph data. It is an excellent tool for data analysts and data science enthusiasts to explore and understand graphs.

  1. Open Gephi and click on New Project. Then choose File->Open and load the dataset of your choice as shown below. On loading the dataset it would show the number of nodes and edges present in the dataset as well as the type of the graph.

2. Below is how all the nodes and edges are displayed when initially dat is loaded.

3. Now we can represent the data in various layout. In he left pane choose the layout option and choose the layout of your choice and click on Run. In the below image I have chosen the ForceAtlas layout which displays the data in the following form.

4. Next we can differentiate the nodes based on various ranking like there In-Degree, Out-Degree or Degree and show them in different color. For this in the left pane on top side choose Nodes->Ranking there choose the ranking like in below image Out-Degree is chosen.