Installing and using the Neo4j Python driver
We can use the Neo4j Python driver to fetch data from Neo4j and analyze it from Python. In this section, we are going to plot the degree distribution using Python visualization packages.
Counting node labels and relationship types in Python
Let’s open the Neo4j_Driver
notebook (https://github.com/PacktPublishing/Graph-Data-Science-with-Neo4J/blob/main/Chapter03/notebooks/Neo4j_Driver.ipynb). To install the Neo4j driver, run the following code in the first cell:
!pip install neo4j
Let’s instantiate the driver and fetch our first bit of data from Neo4j:
- First, import the required objects:
from collections import defaultdict
from neo4j import GraphDatabase
- Then, instantiate a
driver
object, providing it with the connection parameters:driver = GraphDatabase.driver(
"bolt://localhost:7687",
auth=("neo4j", "<PASSWORD>")
)
- With...