%% Search Nodes by 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

%
% Search the database for nodes that have node label Person using the Neo4j database connection neo4jconn.

nlabel = 'Person';

nodeinfo = searchNode(neo4jconn,nlabel)

% nodeinfo is a table that contains information for each database node:
% Each row name is a node identifier.
% Variable NodeLabels is the node label.
% Variable NodeData is the node information.
% Variable NodeObject is the Neo4jNode object.
%
% Access the node information for the first node in the table. The structure contains one property key and value.

node = nodeinfo.NodeData(1);
node{1}

%
% Access the node information using the row name as an index. The structure contains one property key and value.

nodeinfo.NodeData{'0'}

%
% Find the node degree for the first database node in the table. Specify outgoing relationships. There are two outgoing relationships from the first node in the table with relationship type knows.

degree = nodeDegree(nodeinfo.NodeObject(1),'out')

%
% Close the database connection.

close(neo4jconn)

% Copyright 2018 The MathWorks, Inc.