Degree of Centrality
Historically, the first and conceptually simplest is the degree of centrality, which is defined as the number of links falling on a node (i.e. the number of links that a node has). The degree can be interpreted in terms of the immediate risk that the node could intercept everything that flows over the network (for example, a virus or some information). In the case of a directed network (where the links have direction), we usually define two separate measures of degree centrality, namely degree and degree. Accordingly, undegree — this is the number of links directed to the node, and outdegree — the number of links that a node directs to others. When ties are associated with some positive aspect, such as friendship or cooperation, independence is often interpreted as a form of popularity, and the degree — as sociability.
The degree of centrality of the vertex for this graph with vertices and edges, defined as
Calculating the degree of centrality for all nodes in the graph takes in a dense adjacency matrix a graph representation, and for edges takes in a sparse matrix representation.
The definition of node-level centrality can be extended to the entire graph, in which case we are talking about centralizing the graph. Allow to be the node with the highest degree of centrality in , Let be node associated graph, which maximizes the next value (with being the highest centralized node in ):
Accordingly, the degree of centralization of the graph is:
Value is maximized when the graph contains one central node to which all other nodes are connected (star graph), in which case
Below is the code to calculate the degree of centrality of a graph and its various nodes.
The above function is called using the networkx library and after installing it you can end up using it and the following code must be written in python to implement node degree centrality.
The result looks like this: