Hello All,
In relational database when we run some complex query of multiple joins we can create table/MV of that resulting set and then can run other queries on top of table .
Similarly in neo4j when I executed following query I get some result . Now I want to run Louvain algorithm on the result i received from this .
Do I need to put the result of this query in some graph and then run algo on top of it ?
How can I achieve this ? Do I need to project result of this query ?
match(n1:ClientInfo)-[:ACCESSED]->()<-[:ACCESSED]-(n2:ClientInfo)
--where n1.peopleCode = 304989205
with n1, n2, count(*) as commonDocs
with n1, n2, commonDocs, count{(n1)-[:ACCESSED]->()} as n1Docs, count{(n2)-[:ACCESSED]->()} as n2Docs
with n1, n2, n2Docs,n1Docs,commonDocs, round(toFloat(commonDocs) / toFloat(n1Docs + n2Docs - commonDocs), 2) as similarity
return n1.ClientFirstName+' ' +n1.ClientLastName, n2.ClientFirstName+' ' +n2.ClientLastName, commonDocs,n1Docs,n2Docs,similarity
The Louvain algorithm is part of the Neoj Graph Data Science library (GDS). The GDS algorithms run on a projection of your neo4j data, not directly on the neo4j data. As such, you need to project your data first. You then pass your projection’s name as a parameter to a GDS library method.
As you will see, there are both native and cypher projections.
Once you have a projection, here is the Louvain reference:
hello @glilienfield
I tried doing it but getting error . Can we not pass multiple relationship type in graph projection
match(n1:ClientInfo)-[:ACCESSED]->()<-[:ACCESSED]-(n2:ClientInfo)
with n1, n2, count(*) as commonDocs
with n1, n2, commonDocs, count{(n1)-[:ACCESSED]->()} as n1Docs, count{(n2)-[:ACCESSED]->()} as n2Docs
where commonDocs >=5 and n1.peopleCode <>310962818
with n1, n2, apoc.create.vRelationship(n1,'HAS_COMMON_DOCS',{commonDocs:commonDocs}, n2)
with gds.graph.project(
'users',
['ClientInfo', 'DocInfo'],
['ACCESSED','HAS_COMMON_DOCS']
)YIELD
graphName AS graph, nodeProjection, nodeCount AS nodes, relationshipProjection, relationshipCount AS rels;
Invalid input 'YIELD': expected
"!="
"%"
"*"
"+"
","
"-"
"/"
"::"
"<"
"<="
"<>"
"="
"=~"
">"
">="
"AND"
"AS"
"CALL"
"CONTAINS"
"CREATE"
"DELETE"
"DETACH"
"ENDS"
"FOREACH"
"IN"
"IS"
"LIMIT"
"LOAD"
"MATCH"
"MERGE"
"OPTIONAL"
"OR"
"ORDER"
"REMOVE"
"RETURN"
"SET"
"SKIP"
"STARTS"
"UNION"
"UNWIND"
"USE"
"WHERE"
"WITH"
"XOR"
"^"
(line 11, column 2 (offset: 451))
")YIELD"