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 be the adjacency matrix of a directed graph. The in-degree centrality of node is given by: or in matrix form (1 is a vector with all components equal to unity): The out-degree centrality of node is given by: or in matrix form:
Trait | Value |
---|---|
Module type | algorithm |
Implementation | C++ |
Graph direction | directed/undirected |
Edge weights | unweighted |
Parallelism | sequential |
Procedures
You can execute this algorithm on graph projections, subgraphs or portions of the graph.
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 |
| ... | ... |
+------------------+------------------+