Module raphtory::algorithms

source ·
Expand description

Implementations of various graph algorithms that can be run on the graph.

The algorithms are grouped into modules based on the type of graph they can be run on.

To run an algorithm simply import the module and call the function.

Examples

use raphtory::algorithms::degree::{average_degree};
use raphtory::db::graph::Graph;
  
 let g = Graph::new(1);
 let vs = vec![
     (1, 1, 2),
     (2, 1, 3),
     (3, 2, 1),
     (4, 3, 2),
     (5, 1, 4),
     (6, 4, 5),
  ];

 for (t, src, dst) in &vs {
   g.add_edge(*t, *src, *dst, &vec![], None);
 };
println!("average_degree: {:?}", average_degree(&g));

Modules

Varying degree calculations for the entire graph. The degree of a vertex is the number of edges connected to it.
Graph density - measures how dense or sparse a graph is.
Local Clustering coefficient - measures the degree to which nodes in a graph tend to cluster together.
Local triangle count - calculates the number of triangles (a cycle of length 3) for a node. It measures the local clustering of a graph.
Reciprocity - measure of the symmetry of relationships in a 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 edges.
Computes the number of both open and closed triplets within a graph