unobtanium-graph-algorithms 0.1.0

Graph ranking algorithms for the unobtanium search engine
Documentation
// SPDX-FileCopyrightText: 2025 Slatian 2025
//
// SPDX-License-Identifier: LGPL-3.0-only

/// Parameters for the pagerank algorithm
#[derive(Debug, Clone)]
pub struct PageRankConfiguration {
	/// Works as in "Bringing Order into Texts", the TextRank paper.
	///
	/// ```notest
	/// score = (1 - damping) + damping * {pagerank calculation}
	/// ```
	pub damping: f32,

	/// The convergence threshold.
	///
	/// If no single value changes more than this from one iteration to another
	/// the weights are considered successfully converged.
	pub tolerance: f32,
}

impl Default for PageRankConfiguration {
	fn default() -> Self {
		Self {
			damping: Self::DEFAULT_TEXTRANK_DAMPING,
			tolerance: Self::DEFAULT_TEXTRANK_TOLERANCE,
		}
	}
}

impl PageRankConfiguration {
	/// The default damping factor used for textrank
	pub const DEFAULT_TEXTRANK_DAMPING: f32 = 0.85;

	/// The convergence threshold used in the textrank paper.
	pub const DEFAULT_TEXTRANK_TOLERANCE: f32 = 0.0001;
}