Crates.io | page_rank |
lib.rs | page_rank |
version | 0.2.0 |
source | src |
created_at | 2024-05-02 18:12:55.877715 |
updated_at | 2024-05-04 15:13:41.088867 |
description | A graph and pagerank algorithm implementation in Rust |
homepage | |
repository | https://git.arlofilley.com/Arlo/PageRank |
max_upload_size | |
id | 1227957 |
size | 7,863 |
This project implements the PageRank algorithm in Rust using a graph data structure. PageRank is a link analysis algorithm used by Google Search to rank web pages in their search engine results. It assigns a numerical weighting to each element of a hyperlinked set of documents, such as the World Wide Web, with the purpose of measuring its relative importance within the set. This README provides an overview of the project structure and how to use it.
To use this PageRank implementation, follow these steps:
use page_rank::Graph;
fn main() {
let mut pages: Graph<char> = Graph::new();
// Add pages and links here
}
add_page
method:pages.add_page('A');
pages.add_page('B');
// Add more pages as needed
add_link
method:pages.add_link('A', 'E');
pages.add_link('B', 'A');
// Add more links as needed
page_rank
method:pages.page_rank(40); // Specify the depth of the algorithm
for (page, score) in pages.get_sorted_scores() {
println!("{page} => {score:.2}")
}
main
function: Entry point of the program where the graph is initialized and the PageRank algorithm is executed.Graph
struct: Represents the graph data structure containing nodes and their connections.Node
struct: Represents a node in the graph, storing incoming and outgoing links along with their scores.new
: Initializes a new graph or node.add_page
: Adds a page to the graph.add_link
: Adds a link between two pages.page_rank
: Executes the PageRank algorithm to calculate scores.get_sorted_scores
: Retrieves the sorted PageRank scores.This project has no external dependencies beyond the standard Rust library.
PageRank is an algorithm used by search engines to rank web pages in their search results. It works by counting the number and quality of links to a page to determine a rough estimate of the website's importance. Pages with higher PageRank are more likely to appear at the top of search results.
This project is licensed under the MIT License. Feel free to use and modify it according to your needs. If you find any issues or have suggestions for improvements, please create an issue or pull request on the GitHub repository.