Main Content

nodeDegree

In-degree and out-degree for each associated relationship type for Neo4j database node

Description

degree = nodeDegree(node,direction) returns the in- or out-degree for each relationship for the specified Neo4jNode object. direction specifies the relationship direction.

example

Examples

collapse all

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 node with node identifier 2 using the Neo4j® database connection neo4jconn.

nodeid = 2;
node = searchNodeByID(neo4jconn,nodeid);

Search for the degree of all incoming relationships for the node. degree returns a structure with the in-degree for each relationship type.

degree = nodeDegree(node,'in')
degree = struct with fields:
    knows: 1

Close the database connection.

close(neo4jconn)

Input Arguments

collapse all

Neo4j database node, specified as a Neo4jNode object created using searchNode or searchNodeByID.

Relationship direction, specified as either 'in' for an incoming relationship or 'out' for an outgoing relationship. The relationships are associated with the specified origin node.

Output Arguments

collapse all

In- or out-degree, returned as a structure. Each field in the structure represents either incoming or outgoing relationship types. If there are no incoming or outgoing relationship types, the structure is empty.

Version History

Introduced in R2016b