Create two relationships between nodes in a Neo4j® database and display the relationships.
Assume that you have graph data stored in a Neo4j database that represents a social neighborhood. This database has seven nodes and eight relationships. Each node has only one unique property key name
with a value ranging from User1
through User7
. Each relationship has the type knows
.
Create a Neo4j database connection using the URL http://localhost:7474/db/data
, user name neo4j
, and password matlab
.
Check the Message
property of the Neo4j connection object neo4jconn
. The blank Message
property indicates a successful connection.
Search for the node with the label Person
and the property key name
set to the value User7
by using the Neo4j database connection.
Create two nodes in the database using the Neo4j database connection. Use the 'Labels'
name-value pair argument to specify the label Person
for each node.
Create two relationships using the Neo4j database connection. Specify the relationship types as works with
and studies with
. The two relationships are:
User8
works with User7
User8
studies with User9
relationinfo=2×5 table
StartNodeID RelationType EndNodeID RelationData RelationObject
___________ ______________ _________ ____________ _______________________________________
9 6 'works with' 9 [1×1 struct] [1x1 database.neo4j.http.Neo4jRelation]
7 6 'studies with' 7 [1×1 struct] [1x1 database.neo4j.http.Neo4jRelation]
relationinfo
is a table with these variables:
Start node identifier
Relationship type
End node identifier
Relationship data
Neo4jRelation
object
Display the Neo4jRelation
object for the first relationship.
relation =
Neo4jRelation with properties:
RelationID: 9
RelationData: [1×1 struct]
StartNodeID: 6
RelationType: 'works with'
EndNodeID: 9
relation
is a Neo4jRelation
object with these properties:
Relationship identifier
Relationship data
Start node identifier
Relationship type
End node identifier
Close the database connection.