Neo4j : Label Propagation with seed labels

I would like to apply label propagation to my data in Neo4j with seed labels and weight property. My data looks like the image.

The relationship 'Appears_in' has the weight property (integers like 8 in the image) and some articles nodes has seed label property (strings, for example Iphone).

I would like to propagate this seed labels to create clusters with the articles that speaks about the same topic, for example Iphone cluster. More precisely I would like to propagate seed label to another article node but articles do not have a direct relationship between them. They are 'somewhere' connected through the words that they have in commun...

Firstly, I ran weakly connected component in order to keep the only one big network I have in my data :

So I tried to kept the network with 2170 nodes and I projected a bipartite graph to a monopartite with the cypher projection. In the next step, I ran the Label Propagation algorithm. Here is the code :

The results are not good.

I would like to give seed labels (strings) and the weights (that are in the relationships) to the Label Propagation Algorithm.

I would like to have few clusters (I guess 5 clusters if I have 5 seed labels (strings))

I have 5 nodes with seed labels (strings) and I would like to propagate these seed labels throught the network.

For example : The 5 seed labels (strings) would be 'Iphone', 'Coronavirus', 'Disney', 'Crisis', 'Summer'.

How can I write the Label Propagation to propagate these seed labels (strings) ?

Our algorithms only accept numerical values as seeds, so the first thing you'd need would be to convert your strings into numbers (eg. 1, 2, 3, 4, 5). You can use a cypher query to first set a property on each article with it's seed. Probably something like:

MATCH (n:Article)<-[:APPEARS_IN]-(b:KEYWORD)
WHERE n.familyComponent = 0 
AND b.name = 'Disney'
SET n.seed_label = 0

You'd have to modify the query to account for articles with occurrences of multiple key words (maybe take the majority vote?).

Once you've done that, you can run seeded LPA with seedProperty: 'seed_label' (see https://neo4j.com/docs/graph-data-science/current/algorithms/label-propagation/#algorithms-label-propagation-examples-seeded for more details).

1 Like

Thank you for your answer