Last active
August 18, 2019 14:34
-
-
Save vladbatushkov/23c4b8d7212979871c6a07f9e05a809a to your computer and use it in GitHub Desktop.
Apply Degree Centrality vs calculate it Manualy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// algorithm | |
CALL algo.degree.stream("City", "CONNECT_WITH", { direction: "both", weightProperty: "calls" }) YIELD nodeId, score | |
RETURN algo.asNode(nodeId).name AS name, score | |
ORDER BY score DESC | |
// manual calculation | |
MATCH (c:City)-[cw:CONNECT_WITH]-(:City) | |
RETURN c.name as name, SUM(cw.calls) as score | |
ORDER BY score DESC | |
// projection | |
CALL algo.degree( | |
'MATCH (c:City) RETURN id(c) as id', | |
'MATCH (c1:City)<-[:FROM]-(:Person)-[OUT]->(:Call)<-[]-(:Person)-[:FROM]->(c2:City) WHERE id(c1) <> id(c2) RETURN id(c1) as source, id(c2) as target', | |
{ graph:'cypher', write: true, writeProperty: "degree" } | |
) | |
// compare | |
MATCH (c:City)-[cw:CONNECT_WITH]-(:City) | |
WITH c.name as name, c.population as population, c.calls as internal, SUM(cw.calls) as external | |
RETURN name, population, internal + external as total | |
ORDER BY population DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment