This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


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


degree = nodeDegree(node,direction)



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


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.

ans =


The blank Message property indicates a successful connection.

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 = nodeDegree(node,'in')
degree = 

  struct with fields:

    knows: 1

degree returns a structure with the in-degree for each relationship type.

Input Arguments

collapse all

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

Relationship direction, specified as one of these values. The relationships are associated with the specified origin node.



Incoming relationship


Outgoing relationship

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.

Introduced in R2016b

Was this topic helpful?