hi all:
i'm running label propagation algorithm to detect the community structure. I used the following 3 methods to get the community.however the first one got the wrong result. it partitioned the whole network as one community which is obviously unreasonable. The other two worked correctly and partitioned the network into two communities.
Hi @xiexiexxs,
Welcome to the Neo4j community!!
Do you have any query in the above post?
query? you mean the cypher clauses?
MERGE (nAlice:node {id:'Alice'}) SET nAlice.seed_label=52
MERGE (nBridget:node {id:'Bridget'}) SET nBridget.seed_label=21
MERGE (nDoug:node {id:'Doug'}) SET nDoug.seed_label=21
MERGE (nMark:node {id:'Mark'}) SET nMark.seed_label=19
MERGE (nMichael:node {id:'Michael'}) SET nMichael.seed_label=52
MERGE (nAlice)-[:FOLLOW]->(nBridget)
MERGE (nMark)-[:FOLLOW]->(nDoug)
MERGE (nBridget)-[:FOLLOW]->(nMichael)
MERGE (nDoug)-[:FOLLOW]->(nMark)
MERGE (nMichael)-[:FOLLOW]->(nAlice)
MERGE (nAlice)-[:FOLLOW]->(nMichael)
MERGE (nBridget)-[:FOLLOW]->(nAlice)
MERGE (nMichael)-[:FOLLOW]->(nBridget)
CALL algo.labelPropagation(
'MATCH (a:node) RETURN id(a) as id',
'MATCH (a:node)-[r:FOLLOW]-(b:node) RETURN id(a) as source ,id(b) as target',
{graph:'cypher',iterations:50,partitionProperty:'seed_label',write:true,writeProperty:'s1'}
)
CALL algo.labelPropagation(
'MATCH (a:node) RETURN id(a) as id',
'MATCH (a:node)-[r:FOLLOW]-(b:node) RETURN id(a) as source ,id(b) as target',
{graph:'cypher',iterations:50,write:true,writeProperty:'s2'}
)
CALL algo.labelPropagation('node','FOLLOW',
{iterations:50,partitionProperty:'seed_label',write:true,writeProperty:'s3'}
)
Sorry for confusion. What I mean was, do you have any question ?
yes, my question is that why the first call procedure(shown in the first figure) got the wrong community(shown in table as s1)? in my view,the three procedures doesn't diff much.
You need to return the seed property in the Cypher statement in your first algo call:
CALL. algo.labelPropagation(
'MATCH (a:node) RETURN id(a) as a, a.seed_label as seed_label',
'MATCH (a:node) -[r:FOLLOW)-(b:node) RETURN id(a) as source, id(b) as target',
{graph:'cypher', partitionProperty:'seed_label',write:true, writeProperty:'s1'}
)
Without specifying the seed property value returned from the node query, there's no way for the algorithm to know what values to use.
great ! solved my problem perfectly!
I mistakenly thought that the partitionProperty would find the property named 'seed_label' from the the quried node as nodes have a property named 'seed_label' ,without explicitly soecifying it.
thanks a lot!