Computing degree centrality involves sorting nodes based on how many relationships they have. This can be computed with base Cypher or invoked via the GDS plugin and a projected graph.
Formula
Degree centrality Cn is defined as follows:
Cn = deg(n)
Here, deg(n) denotes the number of edges connected to the node n.
If your graph is directed, then you can define the incoming and outgoing degree as the number of relationships starting from node n and the number of relationships ending in n, respectively.
For instance, let's consider the following graph:
Node A has one incoming relationship (coming from B) and two outgoing relationships (to B and D), so its incoming degree is 1 and its outgoing degree is 2. The degrees of each node are summarized in the following table:
Node | Outgoing degree | Incoming degree | Degree (undirected) |
A | 2 | 1 | 3 |
B | 1 | 3 | 4 |
C | 1 | 0 | 1 |
D | 1 | 1 | 2 |
Let's now see how to get these results in Neo4j. You can create this small graph...