![]() |
STAG Python
1.2.1
Spectral Toolkit of Algorithms for Graphs
|
The stag.neo4j.Neo4jGraph object provides a convenient interface with Neo4j, a popular graph database. This allows graph algorithms to be executed directly on a graph stored in the database.
This tutorial will give a quick introduction to Neo4j and demonstrate how to run your first graph algorithms on a graph stored in Neo4j. In this tutorial, we will connect to a Neo4j database running in the AuraDB cloud service. The STAG library can also connect to a database running locally.
You should begin by following the introductory steps in the Neo4j documentation to set up a database in the cloud using the AuraDB service. We recommend first experimenting with the provided 'Movie' dataset. You will need to note the following information when you create the new database instance.
Once the database instance is up and running, you can connect to it with the following code.
Then, we can test that the connection was successful by querying the database. This command will return the degree of the node with ID 0.
Once we have connected successfully to the database, we can find a cluster in the data.
Then, assuming we are testing against the Neo4j movies dataset, we can display the cluster as follows.