I want to subset my graph instance and get closeness centrality output for just one specific type of entity. Is there any way to optimize my query?
I am running the following cypher query:
CALL algo.closeness.stream('MATCH (p) WHERE ANY(lbl IN ["PERSON", "CITATION", "BIOTERM"] WHERE lbl IN LABELS(p)) RETURN id(p) as id',
'MATCH (p1)-[r]->(p2) RETURN id(p1) as source,id(p2) as target',
YIELD nodeId, centrality
RETURN labels(algo.asNode(nodeId)) AS nodeType, nodeId AS nodeId, centrality LIMIT 100;
I think I am able to subset my graph using the cypher query in the first argument of the CALL algo.closeness.stream. I get the centrality scores of all the three type of nodes "PERSON", "CITATION" and "BIOTERM". I know that I can modify my RETURN statement to limit output only for my "PERSON". But I am wondering if there is a way to optimize the algorithm so it computes and fetches the output for "PERSON" nodes.
In other words, I want the algorithm to find shortest paths in my graph induced by the "PERSON", "CITATION" and "BIOTERM" nodes, but computes the centrality measure only for the "PERSON" nodes.