Applying Louvain algorithm on a Bipartite Graph

Hi,

I have a weighted bipartite graph with 2 node labels and a score as a relationship property. I tried applying Louvain algorithm using Bloom as well the commands provided in this example: Louvain - Neo4j Graph Data Science

I am not getting similar results. The number of communities shown in bloom is 7 and in using gds.stream, it shows 65 communities. Could you please explain the discrepancy in the results?

Thanks

Hello @kamalika.ray ,
Bloom executes the GDS algorithms over the current scence (Graph Data Science integration - Neo4j Bloom).
I suspect that your scene in Bloom does not capture the whole graph, hence you find less communities compared to running GDS directly.

Hi @florentin_dorre,

Thank you for your answer. I figured out the issue.
I had another question, I want to specify the nodes without properties while creating the in-memory graph. How can I do that instead of using '*'?

CALL gds.graph.project(
'myGraph',
'*',
{
RESPONSIBLE_FOR: {
orientation: 'UNDIRECTED'
}
},
{
relationshipProperties: 'score'
}
)

instead of '*' you can also can also use labels such as ['Label1', 'Label2']. See Projecting graphs using native projections - Neo4j Graph Data Science.

If your node selection gets more complex than labels, you want to look into cypher-projection (Projecting graphs using Cypher - Neo4j Graph Data Science).

1 Like

Okay. I will use this. Thanks a lot. I am trying to add the Louvain scores to each node. How can I do that? In the example I only see the command for adding the communityId:

CALL gds.louvain.write('myGraph', { writeProperty: 'community' })

I am trying this command but it write the id itself:

CALL gds.louvain.write('myGraph', { writeProperty: 'Louvain_score' })

Yes write should work for your case. If you dont want to change the persistent data directly you can also use mutate.

What scores do you mean? Do you mean the modularity for each community?

Hi,

Sorry, yes I mean modularity for each community.

Thanks

Then I would suggest to look into Modularity metric - Neo4j Graph Data Science as a post-processing step.

1 Like