Search code examples
neo4jcyphergraph-algorithmneo4j-apoc

Degree centrality algorithm returns only 0.0 as score


I'm trying to run the degree centrality algorithm on my dataset. The submodel of my query looks like this:

(transfer:Transfer)-[:PARENT_TRANSFER]->(hasUnderlyingBatch:HasUnderlyingBatch)

The query that I'm trying to run:

CALL algo.degree.stream("Transfer", "PARENT_TRANSFER", {direction:"outgoing"}) YIELD nodeId, score 
RETURN nodeId, score ORDER BY score DESC

I have verified that these relations exist, but I received a score of 0.0 for each record nonetheless.

When I implement the query myself, I do get proper results:

MATCH (t:Transfer) 
RETURN t.Code, size((t)-[:PARENT_TRANSFER]->()) as score 
ORDER BY score DESC

Could anyone explain to me why I'm not getting the proper results when using the degree centrality algorithm?


Solution

  • Your PARENT_TRANSFER relationship is between a node Transfer and HasUnderlyingBatch.

    Or in the call of the algo, you are only using nodes with a label Transfer, so it's normal that you have no result.

    What you have to do is a cypher projection of your graph, if you really want to do an algo between yours Transfer and HasUnderlyingBatch (but it seems weird for me, because you mix apples and bananas).