removeNodeLabel
Remove labels from nodes in Neo4j database
Description
Examples
Remove One Node Label
Add one node label to a single node in a Neo4j® database, access the node, and then remove the new node label.
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 = []
Retrieve the first node in the table of node information. This node has the label Person
.
nlabel = "Person";
nodeinfo = searchNode(neo4jconn,nlabel);
node = nodeinfo.NodeObject(1);
Add one node label to a single node in the database using the Neo4j database connection.
labels = "Analyst";
addNodeLabel(neo4jconn,node,labels)
Display the node information for the updated node.
nodeinfo = searchNode(neo4jconn,labels); node.NodeLabels
ans = 2×1 cell array
{'Person' }
{'Analyst'}
Remove the label Analyst
from the updated node.
removeNodeLabel(neo4jconn,node,labels)
Find the first node again and display its node labels. The node now has only the label Person
.
nlabel = "Person";
nodeinfo = searchNode(neo4jconn,nlabel);
nodeinfo.NodeLabels(1)
ans = 1×1 cell array
{'Person'}
Close the database connection.
close(neo4jconn)
Remove Multiple Node Labels and Return Output
Add node labels to multiple nodes in a Neo4j® database, remove the new node labels, and access the updated node information using an output argument.
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 = []
Find nodes with the label Person
.
nlabel = "Person";
nodeinfo = searchNode(neo4jconn,nlabel);
Add multiple node labels to the nodes in the database using the Neo4j database connection.
labels = ["Analyst" "Scientist"]; node = nodeinfo.NodeObject; addNodeLabel(neo4jconn,node,labels)
Display the node information for the updated nodes. Each node has three node labels (Person
, Analyst
, and Scientist
).
nlabel = "Analyst";
nodeinfo = searchNode(neo4jconn,nlabel);
nodeinfo.NodeLabels
ans = 7×1 cell array
{3×1 cell}
{3×1 cell}
{3×1 cell}
{3×1 cell}
{3×1 cell}
{3×1 cell}
{3×1 cell}
Remove the labels Analyst
and Scientist
from the updated nodes and display updated node information. Each node now has only the label Person
. The nodeinfo
output argument is a Neo4jNode
object.
nodeinfo = removeNodeLabel(neo4jconn,node,labels); nodeinfo.NodeLabels
ans = 7×1 cell array
{'Person'}
{'Person'}
{'Person'}
{'Person'}
{'Person'}
{'Person'}
{'Person'}
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]
labels
— Node labels
character vector | cell array of character vectors | string scalar | string array
Node labels, specified as a character vector, cell array of character vectors, string scalar, or string array. To specify one node label, use a character vector or string scalar. For multiple node labels, use a cell array of character vectors or a string array.
Example: "Person"
Data Types: char
| string
| cell
Output Arguments
nodeinfo
— Node information
Neo4jNode
object | table
Node information in the Neo4j database, returned as a Neo4jNode
object for one node or as a table for multiple nodes.
For multiple nodes, the table contains these variables:
NodeLabels
— Cell array of character vectors that contains the node labels for each database nodeNodeData
— Cell array of structures that contains node information such as property keysNodeObject
—Neo4jNode
object for each database node
The row names of the table are Neo4j node identifiers of each database node.
Version History
Introduced in R2019a
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)