cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to get Degree centrality in bipartite graph by using GDS?

gigauser
Graph Buddy

I tried to find Ingredients DC in the Recipe graph from GDS playground but found no way to get it.
I found a video explaining it easily with other method but it seems not so easy with GDS:

I tried several things I can imagine but still failed:

call gds.alpha.degree.stream({
nodeProjection: ['Ingredient', 'Recipe'],
relationshipProjection: 'CONTAINS_INGREDIENT'}) yield nodeId, score
match (n) where id(n)= nodeId
return n, score order by score desc limit 10
==> this returns scores for Recipe not Ingredient.

I know how to get the number of edges of Ingredients and divide them with the total number of Recipe and it will be DC of Ingredients:
match p = (i:Ingredient)--(:Recipe) return i, count(p) as degree order by degree desc limit 10

But I need to show customer doing it with GDS if there is a way.

1 ACCEPTED SOLUTION

I think you need to inverse your relationship direction for GDS

otherwise you can also just use size( (ingredient)<-[:CONTAINS_INGREDIENT]-()) as degree in a regular cypher query.

View solution in original post

2 REPLIES 2

I think you need to inverse your relationship direction for GDS

otherwise you can also just use size( (ingredient)<-[:CONTAINS_INGREDIENT]-()) as degree in a regular cypher query.

Hi Michael.
Yes. Now I found it in the latter part of the guide.
https://guides.neo4j.com/4.0-intro-graph-algos-exercises/PracticalApplication.html

Happy Christmas!
Dongho.