deleteNode
Delete nodes from Neo4j database
Description
Examples
Delete Node
Create a single node in a Neo4j® database and delete the node.
Create a Neo4j database connection using the URL http://localhost:7474/db/data
, user name neo4j
, and password matlab
.
url = 'http://localhost:7474/db/data'; username = 'neo4j'; password = 'matlab'; neo4jconn = neo4j(url,username,password);
Check the Message
property of the Neo4j connection object neo4jconn
. The blank Message
property indicates a successful connection.
neo4jconn.Message
ans = []
Create a single node in the Neo4j database using the Neo4j database connection.
node = createNode(neo4jconn)
node = Neo4jNode with properties: NodeID: 7 NodeData: [1×1 struct] NodeLabels: []
node
is a Neo4jNode
object with these properties:
Node identifier
Node data
Node label
Delete the node using the Neo4j database connection.
deleteNode(neo4jconn,node)
Close the database connection.
close(neo4jconn)
Delete Node and Its Relationship
Create a single relationship between two nodes in a Neo4j® database. Then, delete one of the nodes and the relationship.
Create a Neo4j database connection using the URL http://localhost:7474/db/data
, user name neo4j
, and password matlab
.
url = 'http://localhost:7474/db/data'; username = 'neo4j'; password = 'matlab'; neo4jconn = neo4j(url,username,password);
Check the Message
property of the Neo4j connection object neo4jconn
. The blank Message
property indicates a successful connection.
neo4jconn.Message
ans = []
Create two nodes in the Neo4j database using the Neo4j database connection. Use the 'Labels'
name-value pair argument to specify the Person
node label for each node.
label = 'Person'; startnode = createNode(neo4jconn,'Labels',label); endnode = createNode(neo4jconn,'Labels',label);
Create a relationship between two nodes using the Neo4j database connection. Specify the relationship type as works with
.
relationtype = 'works with';
relation = createRelation(neo4jconn,startnode,endnode,relationtype)
relation = Neo4jRelation with properties: RelationID: 19 RelationData: [1×1 struct] StartNodeID: 14 RelationType: 'works with' EndNodeID: 15
relation
is a Neo4jRelation
object with these properties:
Relationship identifier
Relationship data
Start node identifier
Relationship type
End node identifier
Delete the first node and the associated relationship. Use this syntax to delete the node and relationship without throwing an error.
deleteNode(neo4jconn,startnode,'DeleteRelations',true)
Close the database connection.
close(neo4jconn)
Input Arguments
neo4jconn
— Neo4j database connection
Neo4jConnect
object
Neo4j database connection, specified as a Neo4jConnect
object created with the function neo4j
.
node
— Node
Neo4jNode
object | Neo4jNode
object array | numeric scalar | numeric vector
Node in a Neo4j database, specified as a Neo4jNode
object, Neo4jNode
object array, numeric scalar,
or a numeric vector. For one node, specify a Neo4jNode
object or a
numeric scalar. For multiple nodes, specify a Neo4jNode
object array or
a numeric vector.
The numeric scalar or vector must contain Neo4j database node identifiers.
Example: 15
Example: [2,3,4]
Version History
Introduced in R2018a
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)