%% Create Two Nodes with Labels and Properties
% Create two nodes with labels and properties in a Neo4j® database. Access the data in the nodes.
% 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.

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

%
% Create a table with two rows that contain the names and job titles of two people (users).

props = table(["User8";"User9"],["Analyst";"Technician"], ...
    'VariableNames',{'Name','Title'});

%
% Create two nodes that represent these two people in the database by using the Neo4j database connection. Use the 'Labels' name-value pair argument to specify the node labels Person and Employee. Then, use the 'Properties' name-value pair argument to specify the node properties using the props table.

labels = ["Person","Employee"];
nodeinfo = createNode(neo4jconn,'Labels',labels,'Properties',props)

% nodeinfo is a table with two rows, one for each person. The table contains these variables:
% Node label
% Node data
% Neo4jNode object
%
% Access the properties of the first node. This structure contains the properties of the node as fields and values.

nodeinfo.NodeData{1}

%
% Access the Neo4jNode object for the first node.

data = nodeinfo.NodeObject(1)

% data is a Neo4jNode object with these properties:
% Node identifier
% Node data
% Node label
%
% Close the database connection.

close(neo4jconn)

% Copyright 2018 The MathWorks, Inc.