Main Content

Neo4jRelation

Neo4j database relationship

Description

The Neo4jRelation object represents a single relationship in a Neo4j® database. Use this object to find information about the relationship between two nodes in a Neo4j database.

Creation

Create a Neo4jRelation object using the createRelation, searchRelation, and searchRelationByID functions.

Properties

expand all

This property is read-only.

Relationship identifier, specified as a numeric scalar. The Neo4j database assigns this number automatically.

Example: 3

Data Types: double

This property is read-only.

Relationship data consisting of property keys and values for the unique relationship in the Neo4j database, specified as a structure. If the relationship has no properties, then this structure contains no fields.

Data Types: struct

This property is read-only.

Start node identifier, specified as a numeric scalar. This number specifies the start node of the Neo4j database relationship.

Example: 3

Data Types: double

This property is read-only.

Relationship type, specified as a character vector. This character vector specifies the type of the Neo4j database relationship.

Example: 'knows'

Data Types: char

This property is read-only.

End node identifier, specified as a numeric scalar. This number specifies the end node of the Neo4j database relationship.

Example: 7

Data Types: double

Examples

collapse all

Search for information about a Neo4jRelation object in a Neo4j® database and display the information.

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 values 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
ans =

     []

Search the database for the relationship with the identifier 3 by using the Neo4j database connection.

relationid = 3;

relinfo = searchRelationByID(neo4jconn,relationid)
relinfo = 

  Neo4jRelation with properties:

      RelationID: 3
    RelationData: [1×1 struct]
     StartNodeID: 1
    RelationType: 'knows'
       EndNodeID: 3

relinfo is a Neo4jRelation object with these properties:

  • Relationship identifier

  • Relationship data

  • Start node identifier

  • Relationship type

  • End node identifier

Access the property keys and values of the relationship using the property RelationData. Here, the relationship does not contain properties, so the structure has no fields.

relinfo.RelationData
ans = 

  struct with no fields.

Version History

Introduced in R2018a