cancel
Showing results for 
Search instead for 
Did you mean: 

node centralities for heterogeneous graph

sal-agui
Node Link

My graph has node types: Provider, Diagnosis, Procedure (and more). I want to derive or calculate node centrality for all nodes: degree, pagerank, and eigenvector centralities.

My starting methodology is as follows:

- create a graph projection 

- apply the gds degree centrality on the graph projection to get the centrality for each node.

Here is what I'm having trouble with: 

`query ='''CALL gds.graph.project('mygraph', myNodes, myLinks)'''`

where my myNodes is:

'MATCH (n) where n:Provider or n.Diagnosis return id(n) as id', 

where myLinks is:

` match (s:Provider)-[r:PROVIDES_DIAGNOSIS]-(t:Diagnosis) where r.some_ratio > 0 return id(s) as src, id(t) as trg, r.some_ratio as weight', 

Then I want to apply degree.stream:

CALL gds.degree.stream( 'mygraph')

YIELD nodeId, score

RETURN gds.util.asNode(nodeId).provider_id as provider, score

order by score desc'''

 

Here is the error message ```

{message: Failed to invoke procedure `gds.graph.project`: Caused by: java.lang.IllegalArgumentException: Invalid node projection, one or more labels not found: 'match (n) where n:Diagnosis or n:Provider return id(n) as id'}

 

```query = """ CALL gds.graph.project(
'mygraph',
'match (n) where n:Diagnosis or n:Provider return id(n) as id',
'MATCH(n:Provider)-[r]-(m:Diagnosis) where r.claims_ratio_float > 0 RETURN id(n) as source, id(m) as target, r.claims_ratio_float as weight',
{relationshipProperties: 'weight'}

)"""
result = session.run(query)` 

The query is incorrect, but I can't figure a fix to this query. 

3 REPLIES 3

sal-agui
Node Link

by itself, this query works:  `

MATCH(n:Provider)-[r]-(m:Diagnosis) where r.claims_ratio_float > 0 RETURN id(n) as source, id(m) as target, r.claims_ratio_float as weight limit 10`

sal-agui
Node Link

An other option I found, is to use : 

CALL gds.pageRank.stream({
  nodeQuery:'MATCH (p) WHERE p:Provider or p:Diagnosis
             RETURN id(i) as id',

  relationshipQuery: match (s)-[r:REFERS_RULE_CODE]-(t) where r.risk_score > 0 return id(s)
as source, id(t) as target, r.risk_score as weight
union all
match (s)-[r:PROVIDED_DIAGNOSIS_1]-(t) where r.claims_ratio_float > 0 return id(s) as source,
id(t) as target, r.claims_ratio_float as weight'
relationshipWeightProperty:'weight'}) YIELD nodeId, score

 

sal-agui
Node Link

It looks like (form the docs) that another way to project my graph is to: 

`

CALL gds.graph.project(
'mygraph2',
['Provider','RuleCode','Diagnosis'],
['REFERS_RULE_CODE','PROVIDED_DIAGNOSIS_1'],
{relationshipProperties: 'risk_score'})`
 
The question here is how do I code in the relationshipProperties that it should be risk_score or claims_ratio_float ? can I do  ['risk_score', 'claims_ratio_float']  as the value to the 'relationshipProperties' key?