graphops
Graph algorithms and node embeddings.
[]
= "0.1.0"
PageRank
use ;
use AdjacencyMatrix;
// Adjacency matrix: edge weights (0.0 = no edge)
let adj = vec!;
let scores = pagerank;
assert_eq!;
Weighted PageRank and convergence diagnostics are available via pagerank_weighted and pagerank_run.
Personalized PageRank (seed-biased ranking) is available via personalized_pagerank.
Random walks
Uniform and biased (node2vec-style) random walks, with optional parallelism:
use ;
use AdjacencyMatrix;
let adj = vec!;
let config = WalkConfig ;
let walks = generate_walks;
// walks: Vec<Vec<usize>> -- each walk is a sequence of node indices
For node2vec-style biased walks (with return parameter p and in-out parameter q), use generate_biased_walks. Parallel variants (_parallel suffix) are available with the parallel feature.
Reachability
Count how many nodes each node can reach (forward) and be reached from (backward):
use reachability_counts_edges;
let edges = vec!;
let = reachability_counts_edges;
// forward[0] = 2 (node 0 reaches nodes 1 and 2)
Partitioning
Connected components and label propagation community detection:
use ;
use AdjacencyMatrix;
let adj = vec!;
let components = connected_components;
// components: [0, 0, 1] -- two components
let communities = label_propagation;
Betweenness centrality
Requires the petgraph feature:
use betweenness_centrality;
use *;
let mut g: = new;
let a = g.add_node;
let b = g.add_node;
let c = g.add_node;
g.add_edge;
g.add_edge;
let scores = betweenness_centrality;
// scores[1] is highest (node b is on the only a->c path)
Examples
Feature flags
Optional features: petgraph (petgraph adapters + betweenness centrality), parallel (rayon walk generation), serde.
License
MIT OR Apache-2.0