Documentation: Added ReadMe and License

This commit is contained in:
Arlo Filley 2024-05-02 17:17:42 +01:00
parent f5f6590a94
commit f54794bdfe
2 changed files with 99 additions and 0 deletions

21
License Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Arlo Filley
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

78
ReadMe.md Normal file
View File

@ -0,0 +1,78 @@
### PageRank Algorithm Implementation
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.
#### How to Use
To use this PageRank implementation, follow these steps:
1. Clone the repository or copy the provided code into your Rust project.
2. Ensure you have Rust installed on your system. If not, you can download it from the official [Rust website](https://www.rust-lang.org/).
3. Import the necessary modules:
```rust
use std::{collections::HashMap, hash::Hash};
```
4. Define the main function and initialize the graph:
```rust
fn main() {
let mut pages: Graph<char> = Graph::new();
// Add pages and links here
}
```
5. Add pages to the graph using the `add_page` method:
```rust
pages.add_page('A');
pages.add_page('B');
// Add more pages as needed
```
6. Add links between pages using the `add_link` method:
```rust
pages.add_link('A', 'E');
pages.add_link('B', 'A');
// Add more links as needed
```
7. Run the PageRank algorithm by calling the `page_rank` method:
```rust
pages.page_rank(40); // Specify the depth of the algorithm
```
8. Retrieve and print the sorted PageRank scores:
```rust
for (page, score) in pages.get_sorted_scores() {
println!("{page} => {score:.2}")
}
```
#### Project Structure
- `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.
- Methods:
- `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.
#### Dependencies
This project has no external dependencies beyond the standard Rust library.
#### About PageRank Algorithm
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.
#### License
This project is licensed under the [MIT License](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.