Crates.io | pagerank_rs |
lib.rs | pagerank_rs |
version | 0.1.0 |
source | src |
created_at | 2023-12-27 04:13:56.366139 |
updated_at | 2023-12-27 04:13:56.366139 |
description | A Rust library for computing PageRank, optimized for performance and flexibility. |
homepage | https://github.com/dcadenas/pagerank_rs |
repository | https://github.com/dcadenas/pagerank_rs |
max_upload_size | |
id | 1081416 |
size | 46,183 |
pagerank_rs is a Rust library for computing PageRank, designed to work with graphs of varying sizes. It's a suitable choice for network analysis in different contexts, such as social networks or academic citations. The library aims to provide an efficient way to determine the significance of nodes within a network.
For an in-depth look at the PageRank algorithm, visit its Wikipedia page.
Add pagerank_rs
to your Cargo.toml:
[dependencies]
pagerank_rs = "0.1.0"
Here's a simple example of how to use pagerank_rs:
use pagerank_rs::Pagerank;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut graph = Pagerank::new(3);
graph.link(0, 1)?;
graph.link(1, 2)?;
let probability_of_following_a_link = 0.85;
let tolerance = 0.0001;
graph.rank(probability_of_following_a_link, tolerance, |node_id, rank| {
println!("Node {} rank is {}", node_id, rank);
});
Ok(())
}
This code will output the PageRank of each node in the graph. Node IDs can be any usize integer. The rank values are returned through a closure to avoid allocating a large result object.
For more complex examples and usage patterns, please refer to the unit tests in the repository.
The pagerank_rs library's performance was benchmarked on a graph with 100,000 nodes. Each node is connected to up to 400 other nodes, except for a few nodes that have a significantly higher number of inward links, simulating a more realistic distribution of links.
In tests on an Apple M2 Pro with 32 GB of RAM, the library processed the graph in approximately 1.9 seconds using typical PageRank parameters.
Performance will vary with different graph structures, system hardware, and other environmental factors.
We welcome contributions to pagerank_rs! Here's how to get started:
Please follow the Rust coding conventions and include appropriate documentation.
pagerank_rs is provided under the MIT License. See the LICENSE file for more details.