In the previous section, we saw the important APIs exposed by py2neo along with examples for each of them. In this section, we will further use these APIs and see their practical implementations in real-world scenarios.
Let's recreate the social network data which we created using Cypher in Chapter 2, Querying the Graph with Cypher, using various APIs and methods exposed by py2neo.
First and foremost, we will clean up our database, so perform the following steps to do that:
Open your console or command prompt and execute
<$NEO4J_HOME>\bin\neo4jshell
.Execute the following Cypher queries to delete the data from Neo4j database:
OPTIONAL MATCH (n)-[r]-(n1) delete r,n.n1; MATCH n delete n;
Next we need to write some Python and code using py2neo to create a graph, which will look something like the following figure:
The previous illustration shows the layout of the data model which we will be creating using py2neo APIs.
Perform the following steps to create...