degree_centrality

Degree Centrality is the basic measurement of centrality that refers to the number of edges adjacent to a node. For directed graphs, we define an in-degree measure, which is defined as the number of in-coming edges, and an out-degree measure, defined as the number of out-going edges.

Let A=(ai,j)A = (a_{i,j}) be the adjacency matrix of a directed graph. The in-degree centrality xix_{i} of node ii is given by: xi=kak,ix_{i} = \sum_k a_{k,i} or in matrix form (1 is a vector with all components equal to unity): x=1Ax = 1 A The out-degree centrality yiy_{i} of node ii is given by: yi=kai,ky_{i} = \sum_k a_{i,k} or in matrix form: y=A1y = A 1

docs-source (opens in a new tab)

TraitValue
Module typealgorithm
ImplementationC++
Graph directiondirected/undirected
Edge weightsunweighted
Parallelismsequential

Procedures

get(type)

Output:

  • node ➡ Node in the graph, for which Degree Centrality is calculated.
  • degree ➡ Calculated degree of a node.

Usage:

CALL degree_centrality.get()
YIELD node, degree;

get_subgraph(nodes, relationships, type)

Input:

  • nodes: list[node] ➡ nodes to be used in the algorithm.
  • relationships: list[relationship] ➡ relationships to be considered for degree calculation.
  • type: string (default="undirected") ➡ whether we are using "in", "out", or "undirected" edges.

Output:

  • node ➡ Node in the graph, for which Degree Centrality is calculated.
  • degree ➡ Calculated degree of a node.

Usage:

CALL degree_centrality.get()
YIELD node, degree;

Example

Input graph

Cypher load commands

cypher code for merging and creating relations...

Running command

CALL degree_centrality.get("in")
YIELD node, degree
RETURN node, degree;

Results

+------------------+------------------+
| node             | degree           |
+------------------+------------------+
| (:Node {id: 9})  | 1                |
| ...              | ...              |
+------------------+------------------+