unobtanium_graph_algorithms/
lib.rs

1// SPDX-FileCopyrightText: 2025 Slatian 2025
2//
3// SPDX-License-Identifier: LGPL-3.0-only
4
5#![warn(missing_docs)]
6
7#![doc = include_str!("../README.md")]
8//! ## Where to start
9//!
10//! Construct a [Graph], run one of the `populate_*()` methods and follow its recommendations on a `run_*()` method.
11//!
12//! Example: TextRank keyword extraction
13//! ```rust
14//! use unobtanium_graph_algorithms::Graph;
15//! 
16//! let mut graph = Graph::new();
17//! graph.populate_for_textrank(&["This", "text", "is", "about", "cats", "and", "dogs", "but", "mostly", "dogs"], 2);
18//! let result = graph.run_pagerank(&Default::default());
19//!
20//! // The top word is "dogs"
21//! let top_word = result.sorted_iter().next().unwrap();
22//! assert_eq!(*top_word.0, "dogs");
23//! assert!(top_word.1 > 1.3, "Expected: score (={0}) > 1.3", top_word.1);
24//!
25//! // The total value in the pagerank graph is equal to the result length 
26//! let total_score_sum = result.unsorted_iter().fold(0.0, |a, i| a+i.1);
27//! assert_eq!(result.len() as f32, total_score_sum);
28//! ```
29
30mod graph;
31mod node;
32mod pagerank_configuration;
33
34pub use graph::BrandedNodeId;
35pub use graph::Graph;
36pub use graph::MutableGraph;
37pub use graph::ranked_nodes::RankedNodes;
38pub use graph::ranked_nodes::SortedRankedNodesIter;
39pub use graph::ranked_nodes::UnsortedRankedNodesIter;
40pub use pagerank_configuration::PageRankConfiguration;