Centrality#
- raphtory.algorithms.degree_centrality(g, threads=None)#
Computes the degree centrality of all nodes in the graph. The values are normalized by dividing each result with the maximum possible degree. Graphs with self-loops can have values of centrality greater than 1.
- Parameters:
g (GraphView) – The graph view on which the operation is to be performed.
threads (int, optional) – The number of threads to be used for parallel execution.
- Returns:
A result containing a mapping of node names to the computed sum of their associated degree centrality.
- Return type:
- raphtory.algorithms.pagerank(g, iter_count=20, max_diff=None, use_l2_norm=True, damping_factor=0.85)#
Pagerank – pagerank centrality value of the nodes in a graph
This function calculates the Pagerank value of each node in a graph. See https://en.wikipedia.org/wiki/PageRank for more information on PageRank centrality. A default damping factor of 0.85 is used. This is an iterative algorithm which terminates if the sum of the absolute difference in pagerank values between iterations is less than the max diff value given.
- Parameters:
g (GraphView) – Raphtory graph
iter_count (int) – Maximum number of iterations to run. Note that this will terminate early if convergence is reached.
max_diff (Optional[float]) – Optional parameter providing an alternative stopping condition. The algorithm will terminate if the sum of the absolute difference in pagerank values between iterations is less than the max diff value given.
- Returns:
AlgorithmResult with string keys and float values mapping node names to their pagerank value.
- Return type:
- raphtory.algorithms.hits(g, iter_count=20, threads=None)#
HITS (Hubs and Authority) Algorithm: AuthScore of a node (A) = Sum of HubScore of all nodes pointing at node (A) from previous iteration /
Sum of HubScore of all nodes in the current iteration
- HubScore of a node (A) = Sum of AuthScore of all nodes pointing away from node (A) from previous iteration /
Sum of AuthScore of all nodes in the current iteration
- Parameters:
g (GraphView) – Graph to run the algorithm on
iter_count (int) – How many iterations to run the algorithm
threads (int, optional) – Number of threads to use
- Returns
An AlgorithmResult object containing the mapping from node ID to the hub and authority score of the node
- raphtory.algorithms.betweenness_centrality(g, k=None, normalized=True)#
Computes the betweenness centrality for nodes in a given graph.
- Parameters:
g (GraphView) – A reference to the graph.
k (int, optional) – Specifies the number of nodes to consider for the centrality computation. All nodes are considered by default.
normalized (bool) – Indicates whether to normalize the centrality values.
- Returns:
Returns an AlgorithmResult containing the betweenness centrality of each node.
- Return type: