Centrality#
- raphtory.algorithms.degree_centrality(g, threads=None)#
Computes the degree centrality of all vertices 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 (Raphtory Graph) – The graph view on which the operation is to be performed.
threads (Option<usize>, default = None) – The number of threads to be used for parallel execution. Defaults to single-threaded operation if not provided.
- Returns:
A result containing a mapping of vertex names to the computed sum of their associated degree centrality.
- Return type:
AlgorithmResult<String, OrderedFloat<f64>>
- raphtory.algorithms.pagerank(g, iter_count=20, max_diff=None)#
Pagerank – pagerank centrality value of the vertices in a graph
This function calculates the Pagerank value of each vertex 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 (Raphtory graph) – Raphtory graph
iter_count (int) – Maximum number of iterations to run. Note that this will terminate early if convergence is reached.
max_diff (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 vertex names to their pagerank value.
- Return type:
- raphtory.algorithms.hits(g, iter_count=20, threads=None)#
HITS (Hubs and Authority) Algorithm: AuthScore of a vertex (A) = Sum of HubScore of all vertices pointing at vertex (A) from previous iteration /
Sum of HubScore of all vertices in the current iteration
- HubScore of a vertex (A) = Sum of AuthScore of all vertices pointing away from vertex (A) from previous iteration /
Sum of AuthScore of all vertices in the current iteration
- Parameters:
g (Raphtory Graph) – Graph to run the algorithm on
iter_count (int) – How many iterations to run the algorithm
threads (int) – Number of threads to use (optional)
- Returns
An AlgorithmResult object containing the mapping from vertex ID to the hub and authority score of the vertex