Metrics#
- raphtory.algorithms.balance(g, name=..., direction=..., threads=None)#
Sums the weights of edges in the graph based on the specified direction.
This function computes the sum of edge weights based on the direction provided, and can be executed in parallel using a given number of threads.
- Parameters:
g (Raphtory Graph) – The graph view on which the operation is to be performed.
name (str, default = "weight") – The name of the edge property used as the weight. Defaults to “weight” if not provided.
direction (PyDirection, default = PyDirection(“BOTH”)) – Specifies the direction of the edges to be considered for summation. * PyDirection(“OUT”): Only consider outgoing edges. * PyDirection(“IN”): Only consider incoming edges. * PyDirection(“BOTH”): Consider both outgoing and incoming edges. This is the default.
threads (int, 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 node names to the computed sum of their associated edge weights.
- Return type:
AlgorithmResult<String, OrderedFloat<f64>>
- raphtory.algorithms.average_degree(g)#
The average (undirected) degree of all nodes in the graph.
Note that this treats the graph as simple and undirected and is equal to twice the number of undirected edges divided by the number of nodes.
- Parameters:
g (Raphtory graph) – a Raphtory graph
- Returns:
the average degree of the nodes in the graph
- Return type:
float
- raphtory.algorithms.max_degree(g)#
Returns the largest degree found in the graph
- Parameters:
g (Raphtory Graph) – The graph view on which the operation is to be performed.
- Returns:
The largest degree
- Return type:
usize
- raphtory.algorithms.min_degree(g)#
Returns the smallest degree found in the graph
- Parameters:
g (Raphtory Graph) – The graph view on which the operation is to be performed.
- Returns:
The smallest degree found
- Return type:
usize
- raphtory.algorithms.max_in_degree(g)#
The maximum in degree of any node in the graph.
- Parameters:
g (Raphtory graph) – a directed Raphtory graph
- Returns:
value of the largest indegree
- Return type:
int
- raphtory.algorithms.max_out_degree(g)#
The maximum out degree of any node in the graph.
- Parameters:
g (Raphtory graph) – a directed Raphtory graph
- Returns:
value of the largest outdegree
- Return type:
int
- raphtory.algorithms.min_in_degree(g)#
The minimum in degree of any node in the graph.
- Parameters:
g (Raphtory graph) – a directed Raphtory graph
- Returns:
value of the smallest indegree
- Return type:
int
- raphtory.algorithms.min_out_degree(g)#
The minimum out degree of any node in the graph.
- Parameters:
g (Raphtory graph) – a directed Raphtory graph
- Returns:
value of the smallest outdegree
- Return type:
int
- raphtory.algorithms.directed_graph_density(g)#
Graph density - measures how dense or sparse a graph is.
The ratio of the number of directed edges in the graph to the total number of possible directed edges (given by N * (N-1) where N is the number of nodes).
- Parameters:
g (Raphtory graph) – a directed Raphtory graph
- Returns:
Directed graph density of G.
- Return type:
float
- raphtory.algorithms.local_clustering_coefficient(g, v)#
Local clustering coefficient - measures the degree to which nodes in a graph tend to cluster together.
The proportion of pairs of neighbours of a node who are themselves connected.
- Parameters:
g (Raphtory graph) – Raphtory graph, can be directed or undirected but will be treated as undirected.
v (int or str) – node id or name
- Returns:
the local clustering coefficient of node v in g.
- Return type:
float
- raphtory.algorithms.global_clustering_coefficient(g)#
Computes the global clustering coefficient of a graph. The global clustering coefficient is defined as the number of triangles in the graph divided by the number of triplets in the graph.
Note that this is also known as transitivity and is different to the average clustering coefficient.
- Parameters:
g (Raphtory graph) – a Raphtory graph, treated as undirected
- Returns:
the global clustering coefficient of the graph
- Return type:
float
See also
[Triplet Count](triplet_count)
- raphtory.algorithms.global_reciprocity(g)#
Reciprocity - measure of the symmetry of relationships in a graph, the global reciprocity of the entire graph. This calculates the number of reciprocal connections (edges that go in both directions) in a graph and normalizes it by the total number of directed edges.
- Parameters:
g (Raphtory graph) – a directed Raphtory graph
- Returns:
reciprocity of the graph between 0 and 1.
- Return type:
float
- raphtory.algorithms.all_local_reciprocity(g)#
Local reciprocity - measure of the symmetry of relationships associated with a node
This measures the proportion of a node’s outgoing edges which are reciprocated with an incoming edge.
- Parameters:
g (Raphtory graph) – a directed Raphtory graph
- Returns:
AlgorithmResult with string keys and float values mapping each node name to its reciprocity value.
- Return type: