repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/types/filter/nested.rs
lib/edge/python/src/types/filter/nested.rs
use bytemuck::TransparentWrapper; use derive_more::Into; use pyo3::prelude::*; use segment::json_path::JsonPath; use segment::types::{Filter, Nested, NestedCondition}; use crate::repr::*; use crate::types::*; #[pyclass(name = "NestedCondition")] #[derive(Clone, Debug, Into, TransparentWrapper)] #[repr(transparent)] p...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/types/filter/mod.rs
lib/edge/python/src/types/filter/mod.rs
pub mod condition; pub mod field_condition; pub mod geo; pub mod r#match; pub mod min_should; pub mod nested; pub mod range; pub mod value_count; use bytemuck::{TransparentWrapper, TransparentWrapperAlloc as _}; use derive_more::Into; use pyo3::prelude::*; use segment::types::{Filter, MinShould}; pub use self::condit...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/types/filter/min_should.rs
lib/edge/python/src/types/filter/min_should.rs
use bytemuck::{TransparentWrapper as _, TransparentWrapperAlloc as _}; use derive_more::Into; use pyo3::prelude::*; use segment::types::MinShould; use crate::repr::*; use crate::types::filter::condition::PyCondition; #[pyclass(name = "MinShould")] #[derive(Clone, Debug, Into)] pub struct PyMinShould(pub MinShould); ...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/types/filter/condition.rs
lib/edge/python/src/types/filter/condition.rs
use std::fmt; use bytemuck::TransparentWrapper; use derive_more::Into; use pyo3::IntoPyObjectExt as _; use pyo3::prelude::*; use segment::json_path::JsonPath; use segment::types::*; use segment::utils::maybe_arc::MaybeArc; use crate::repr::*; use crate::types::*; #[derive(Clone, Debug, Into, TransparentWrapper)] #[r...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/types/query/mod.rs
lib/edge/python/src/types/query/mod.rs
use std::fmt; use bytemuck::{TransparentWrapper, TransparentWrapperAlloc as _}; use derive_more::Into; use ordered_float::OrderedFloat; use pyo3::prelude::*; use segment::data_types::vectors::{NamedQuery, VectorInternal}; use segment::vector_storage::query::*; use shard::query::query_enum::QueryEnum; use crate::repr:...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/types/formula/expression_interface.rs
lib/edge/python/src/types/formula/expression_interface.rs
use std::fmt; use bytemuck::TransparentWrapper; use pyo3::prelude::*; use crate::repr::*; use crate::*; #[pyclass(name = "Expression")] #[derive(Clone, Debug)] pub enum PyExpressionInterface { Constant { val: f32, }, Variable { var: String, }, Condition { cond: Boxed<PyC...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/types/formula/expression.rs
lib/edge/python/src/types/formula/expression.rs
use std::fmt; use bytemuck::TransparentWrapper; use derive_more::Into; use pyo3::prelude::*; use shard::query::formula::ExpressionInternal; use crate::repr::*; use crate::*; #[derive(Clone, Debug, Into, TransparentWrapper)] #[repr(transparent)] pub struct PyExpression(ExpressionInternal); impl FromPyObject<'_, '_> ...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/types/formula/mod.rs
lib/edge/python/src/types/formula/mod.rs
pub mod expression; pub mod expression_interface; use std::collections::HashMap; use std::fmt; use bytemuck::TransparentWrapper; use derive_more::Into; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use segment::index::query_optimization::rescore_formula::parsed_formula::{ DecayKind, ParsedFormula, }; ...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/config/mod.rs
lib/edge/python/src/config/mod.rs
pub mod quantization; pub mod sparse_vector_data; pub mod vector_data; use std::collections::HashMap; use std::fmt; use bytemuck::TransparentWrapper; use derive_more::Into; use pyo3::prelude::*; use segment::types::*; pub use self::quantization::*; pub use self::sparse_vector_data::*; pub use self::vector_data::*; u...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/config/vector_data.rs
lib/edge/python/src/config/vector_data.rs
use std::collections::HashMap; use std::{fmt, mem}; use bytemuck::TransparentWrapper; use derive_more::Into; use pyo3::IntoPyObjectExt as _; use pyo3::prelude::*; use segment::types::*; use super::quantization::*; use crate::repr::*; #[pyclass(name = "VectorDataConfig")] #[derive(Clone, Debug, Into, TransparentWrapp...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/config/quantization.rs
lib/edge/python/src/config/quantization.rs
use std::fmt; use bytemuck::TransparentWrapper; use derive_more::Into; use pyo3::IntoPyObjectExt as _; use pyo3::prelude::*; use segment::types::*; use crate::repr::*; #[derive(Clone, Debug, Into, TransparentWrapper)] #[repr(transparent)] pub struct PyQuantizationConfig(pub QuantizationConfig); impl FromPyObject<'_...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/python/src/config/sparse_vector_data.rs
lib/edge/python/src/config/sparse_vector_data.rs
use std::collections::HashMap; use std::{fmt, mem}; use bytemuck::TransparentWrapper; use derive_more::Into; use pyo3::prelude::*; use segment::data_types::modifier::Modifier; use segment::index::sparse_index::sparse_index_config::{SparseIndexConfig, SparseIndexType}; use segment::types::*; use super::vector_data::*;...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/src/scroll.rs
lib/edge/src/scroll.rs
use std::collections::HashSet; use std::sync::atomic::AtomicBool; use common::counter::hardware_accumulator::HwMeasurementAcc; use itertools::Itertools as _; use rand::distr::weighted::WeightedIndex; use rand::rngs::StdRng; use rand::{Rng as _, SeedableRng as _}; use segment::common::operation_error::{OperationError, ...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/src/lib.rs
lib/edge/src/lib.rs
pub mod query; pub mod retrieve; pub mod scroll; pub mod search; pub mod update; use std::num::NonZero; use std::path::{Path, PathBuf}; use std::sync::Arc; use std::sync::atomic::AtomicBool; use std::time::Duration; use common::save_on_disk::SaveOnDisk; use fs_err as fs; use parking_lot::Mutex; use segment::common::o...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/src/update.rs
lib/edge/src/update.rs
use std::fmt; use common::counter::hardware_counter::HardwareCounterCell; use segment::common::operation_error::{OperationError, OperationResult}; use shard::operations::CollectionUpdateOperations; use shard::update::*; use crate::Shard; impl Shard { pub fn update(&self, operation: CollectionUpdateOperations) ->...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/src/search.rs
lib/edge/src/search.rs
use std::cmp; use common::counter::hardware_accumulator::HwMeasurementAcc; use segment::common::operation_error::OperationResult; use segment::data_types::modifier::Modifier; use segment::data_types::vectors::QueryVector; use segment::types::{DEFAULT_FULL_SCAN_THRESHOLD, ScoredPoint, WithPayload}; use shard::common::s...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/src/query.rs
lib/edge/src/query.rs
use std::mem; use std::sync::Arc; use std::sync::atomic::AtomicBool; use ahash::AHashSet; use common::counter::hardware_accumulator::HwMeasurementAcc; use ordered_float::OrderedFloat; use segment::common::operation_error::{OperationError, OperationResult}; use segment::common::reciprocal_rank_fusion::rrf_scoring; use ...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/src/retrieve.rs
lib/edge/src/retrieve.rs
use std::sync::atomic::AtomicBool; use common::counter::hardware_accumulator::HwMeasurementAcc; use segment::common::operation_error::OperationResult; use segment::types::{ExtendedPointId, WithPayload, WithPayloadInterface, WithVector}; use shard::retrieve::record_internal::RecordInternal; use shard::retrieve::retriev...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
qdrant/qdrant
https://github.com/qdrant/qdrant/blob/f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd/lib/edge/examples/edge-cli.rs
lib/edge/examples/edge-cli.rs
use std::env; use std::path::Path; fn main() -> anyhow::Result<()> { let args: Vec<_> = env::args().skip(1).take(2).collect(); let [edge_shard_path] = args .try_into() .map_err(|args| anyhow::format_err!("unexpected arguments {args:?}"))?; let _edge_shard = edge::Shard::load(Path::new(&ed...
rust
Apache-2.0
f937d0260ffd7705c6f34d9c25da1e27ebf5ddfd
2026-01-04T15:34:51.524868Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/.github/workflows/scripts/build_directory/src/lib.rs
.github/workflows/scripts/build_directory/src/lib.rs
use std::{ error::Error, fs, path::{Path, PathBuf}, }; static URL_BASE: &str = "https://github.com/TheAlgorithms/Rust/blob/master"; fn good_filepaths(top_dir: &Path) -> Result<Vec<String>, Box<dyn Error>> { let mut good_fs = Vec::new(); if top_dir.is_dir() { for entry in fs::read_dir(top_d...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/.github/workflows/scripts/build_directory/src/main.rs
.github/workflows/scripts/build_directory/src/main.rs
use std::{fs::File, io::Write, path::Path}; use build_directory::build_directory_md; fn main() -> Result<(), std::io::Error> { let mut file = File::create("DIRECTORY.md").unwrap(); // unwrap for panic match build_directory_md(Path::new(".")) { Ok(buf) => { file.write_all("# List of all fil...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/lib.rs
src/lib.rs
pub mod backtracking; pub mod big_integer; pub mod bit_manipulation; pub mod ciphers; pub mod compression; pub mod conversions; pub mod data_structures; pub mod dynamic_programming; pub mod financial; pub mod general; pub mod geometry; pub mod graph; pub mod greedy; pub mod machine_learning; pub mod math; pub mod navig...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/duval_algorithm.rs
src/string/duval_algorithm.rs
//! Implementation of Duval's Algorithm to compute the standard factorization of a string //! into Lyndon words. A Lyndon word is defined as a string that is strictly smaller //! (lexicographically) than any of its nontrivial suffixes. This implementation operates //! in linear time and space. /// Performs Duval's alg...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/anagram.rs
src/string/anagram.rs
use std::collections::HashMap; /// Custom error type representing an invalid character found in the input. #[derive(Debug, PartialEq)] pub enum AnagramError { NonAlphabeticCharacter, } /// Checks if two strings are anagrams, ignoring spaces and case sensitivity. /// /// # Arguments /// /// * `s` - First input str...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/reverse.rs
src/string/reverse.rs
/// Reverses the given string. /// /// # Arguments /// /// * `text` - A string slice that holds the string to be reversed. /// /// # Returns /// /// * A new `String` that is the reverse of the input string. pub fn reverse(text: &str) -> String { text.chars().rev().collect() } #[cfg(test)] mod tests { use super...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/lipogram.rs
src/string/lipogram.rs
use std::collections::HashSet; /// Represents possible errors that can occur when checking for lipograms. #[derive(Debug, PartialEq, Eq)] pub enum LipogramError { /// Indicates that a non-alphabetic character was found in the input. NonAlphabeticCharacter, /// Indicates that a missing character is not in l...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/rabin_karp.rs
src/string/rabin_karp.rs
//! This module implements the Rabin-Karp string searching algorithm. //! It uses a rolling hash technique to find all occurrences of a pattern //! within a target string efficiently. const MOD: usize = 101; const RADIX: usize = 256; /// Finds all starting indices where the `pattern` appears in the `text`. /// /// # ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/suffix_array.rs
src/string/suffix_array.rs
// In computer science, a suffix array is a sorted array of all suffixes of a string. // It is a data structure used in, among others, full-text indices, data-compression algorithms, // and the field of bibliometrics. Source: https://en.wikipedia.org/wiki/Suffix_array use std::cmp::Ordering; #[derive(Clone)] struct S...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/levenshtein_distance.rs
src/string/levenshtein_distance.rs
//! Provides functions to calculate the Levenshtein distance between two strings. //! //! The Levenshtein distance is a measure of the similarity between two strings by calculating the minimum number of single-character //! edits (insertions, deletions, or substitutions) required to change one string into the other. u...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/isomorphism.rs
src/string/isomorphism.rs
//! This module provides functionality to determine whether two strings are isomorphic. //! //! Two strings are considered isomorphic if the characters in one string can be replaced //! by some mapping relation to obtain the other string. use std::collections::HashMap; /// Determines whether two strings are isomorphic...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/run_length_encoding.rs
src/string/run_length_encoding.rs
pub fn run_length_encoding(target: &str) -> String { if target.trim().is_empty() { return "".to_string(); } let mut count: i32 = 0; let mut base_character: String = "".to_string(); let mut encoded_target = String::new(); for c in target.chars() { if base_character == *"" { ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/aho_corasick.rs
src/string/aho_corasick.rs
use std::cell::RefCell; use std::collections::BTreeMap; use std::collections::VecDeque; use std::rc::{Rc, Weak}; #[derive(Default)] struct ACNode { trans: BTreeMap<char, Rc<RefCell<ACNode>>>, suffix: Weak<RefCell<ACNode>>, // the suffix(fail) link lengths: Vec<usize>, // lengths of matched patter...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/autocomplete_using_trie.rs
src/string/autocomplete_using_trie.rs
/* It autocomplete by prefix using added words. word List => ["apple", "orange", "oregano"] prefix => "or" matches => ["orange", "oregano"] */ use std::collections::HashMap; const END: char = '#'; #[derive(Debug)] struct Trie(HashMap<char, Box<Trie>>); impl Trie { fn new() -> Self { Tri...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/boyer_moore_search.rs
src/string/boyer_moore_search.rs
//! This module implements the Boyer-Moore string search algorithm, an efficient method //! for finding all occurrences of a pattern within a given text. The algorithm skips //! sections of the text by leveraging two key rules: the bad character rule and the //! good suffix rule (only the bad character rule is implemen...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/pangram.rs
src/string/pangram.rs
//! This module provides functionality to check if a given string is a pangram. //! //! A pangram is a sentence that contains every letter of the alphabet at least once. //! This module can distinguish between a non-pangram, a regular pangram, and a //! perfect pangram, where each letter appears exactly once. use std:...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/knuth_morris_pratt.rs
src/string/knuth_morris_pratt.rs
//! Knuth-Morris-Pratt string matching algorithm implementation in Rust. //! //! This module contains the implementation of the KMP algorithm, which is used for finding //! occurrences of a pattern string within a text string efficiently. The algorithm preprocesses //! the pattern to create a partial match table, which...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/jaro_winkler_distance.rs
src/string/jaro_winkler_distance.rs
// In computer science and statistics, // the Jaro–Winkler distance is a string metric measuring an edit distance // between two sequences. // It is a variant proposed in 1990 by William E. Winkler // of the Jaro distance metric (1989, Matthew A. Jaro). pub fn jaro_winkler_distance(str1: &str, str2: &str) -> f64 { ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/mod.rs
src/string/mod.rs
mod aho_corasick; mod anagram; mod autocomplete_using_trie; mod boyer_moore_search; mod burrows_wheeler_transform; mod duval_algorithm; mod hamming_distance; mod isogram; mod isomorphism; mod jaro_winkler_distance; mod knuth_morris_pratt; mod levenshtein_distance; mod lipogram; mod manacher; mod palindrome; mod pangram...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/shortest_palindrome.rs
src/string/shortest_palindrome.rs
//! This module provides functions for finding the shortest palindrome //! that can be formed by adding characters to the left of a given string. //! References //! //! - [KMP](https://www.scaler.com/topics/data-structures/kmp-algorithm/) //! - [Prefix Functions and KPM](https://oi-wiki.org/string/kmp/) /// Finds the ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/isogram.rs
src/string/isogram.rs
//! This module provides functionality to check if a given string is an isogram. //! An isogram is a word or phrase in which no letter occurs more than once. use std::collections::HashMap; /// Enum representing possible errors that can occur while checking for isograms. #[derive(Debug, PartialEq, Eq)] pub enum Isogra...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/manacher.rs
src/string/manacher.rs
pub fn manacher(s: String) -> String { let l = s.len(); if l <= 1 { return s; } // MEMO: We need to detect odd palindrome as well, // therefore, inserting dummy string so that // we can find a pair with dummy center character. let mut chars: Vec<char> = Vec::with_capacity(s.len() * ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/palindrome.rs
src/string/palindrome.rs
//! A module for checking if a given string is a palindrome. /// Checks if the given string is a palindrome. /// /// A palindrome is a sequence that reads the same backward as forward. /// This function ignores non-alphanumeric characters and is case-insensitive. /// /// # Arguments /// /// * `s` - A string slice that...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/z_algorithm.rs
src/string/z_algorithm.rs
//! This module provides functionalities to match patterns in strings //! and compute the Z-array for a given input string. /// Calculates the Z-value for a given substring of the input string /// based on a specified pattern. /// /// # Parameters /// - `input_string`: A slice of elements that represents the input str...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/burrows_wheeler_transform.rs
src/string/burrows_wheeler_transform.rs
pub fn burrows_wheeler_transform(input: &str) -> (String, usize) { let len = input.len(); let mut table = Vec::<String>::with_capacity(len); for i in 0..len { table.push(input[i..].to_owned() + &input[..i]); } table.sort_by_key(|a| a.to_lowercase()); let mut encoded = String::new(); ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/suffix_tree.rs
src/string/suffix_tree.rs
// In computer science, a suffix tree (also called PAT tree or, in an earlier form, position tree) // is a compressed trie containing all the suffixes of the given text as their keys and positions // in the text as their values. Suffix trees allow particularly fast implementations of many // important string operations...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/suffix_array_manber_myers.rs
src/string/suffix_array_manber_myers.rs
pub fn generate_suffix_array_manber_myers(input: &str) -> Vec<usize> { if input.is_empty() { return Vec::new(); } let n = input.len(); let mut suffixes: Vec<(usize, &str)> = Vec::with_capacity(n); for (i, _suffix) in input.char_indices() { suffixes.push((i, &input[i..])); } ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/string/hamming_distance.rs
src/string/hamming_distance.rs
/// Error type for Hamming distance calculation. #[derive(Debug, PartialEq)] pub enum HammingDistanceError { InputStringsHaveDifferentLength, } /// Calculates the Hamming distance between two strings. /// /// The Hamming distance is defined as the number of positions at which the corresponding characters of the tw...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/n_queens.rs
src/backtracking/n_queens.rs
//! This module provides functionality to solve the N-Queens problem. //! //! The N-Queens problem is a classic chessboard puzzle where the goal is to //! place N queens on an NxN chessboard so that no two queens threaten each //! other. Queens can attack each other if they share the same row, column, or //! diagonal. ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/parentheses_generator.rs
src/backtracking/parentheses_generator.rs
/// Generates all combinations of well-formed parentheses given a non-negative integer `n`. /// /// This function uses backtracking to generate all possible combinations of well-formed /// parentheses. The resulting combinations are returned as a vector of strings. /// /// # Arguments /// /// * `n` - A non-negative int...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/sudoku.rs
src/backtracking/sudoku.rs
//! A Rust implementation of Sudoku solver using Backtracking. //! //! This module provides functionality to solve Sudoku puzzles using the backtracking algorithm. //! //! GeeksForGeeks: [Sudoku Backtracking](https://www.geeksforgeeks.org/sudoku-backtracking-7/) /// Solves a Sudoku puzzle. /// /// Given a partially fi...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/subset_sum.rs
src/backtracking/subset_sum.rs
//! This module provides functionality to check if there exists a subset of a given set of integers //! that sums to a target value. The implementation uses a recursive backtracking approach. /// Checks if there exists a subset of the given set that sums to the target value. pub fn has_subset_with_sum(set: &[isize], t...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/permutations.rs
src/backtracking/permutations.rs
//! This module provides a function to generate all possible distinct permutations //! of a given collection of integers using a backtracking algorithm. /// Generates all possible distinct permutations of a given vector of integers. /// /// # Arguments /// /// * `nums` - A vector of integers. The input vector is sorte...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/mod.rs
src/backtracking/mod.rs
mod all_combination_of_size_k; mod graph_coloring; mod hamiltonian_cycle; mod knight_tour; mod n_queens; mod parentheses_generator; mod permutations; mod rat_in_maze; mod subset_sum; mod sudoku; pub use all_combination_of_size_k::generate_all_combinations; pub use graph_coloring::generate_colorings; pub use hamiltonia...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/all_combination_of_size_k.rs
src/backtracking/all_combination_of_size_k.rs
//! This module provides a function to generate all possible combinations //! of `k` numbers out of `0...n-1` using a backtracking algorithm. /// Custom error type for combination generation. #[derive(Debug, PartialEq)] pub enum CombinationError { KGreaterThanN, InvalidZeroRange, } /// Generates all possible ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/rat_in_maze.rs
src/backtracking/rat_in_maze.rs
//! This module contains the implementation of the Rat in Maze problem. //! //! The Rat in Maze problem is a classic algorithmic problem where the //! objective is to find a path from the starting position to the exit //! position in a maze. /// Enum representing various errors that can occur while working with mazes....
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/knight_tour.rs
src/backtracking/knight_tour.rs
//! This module contains the implementation of the Knight's Tour problem. //! //! The Knight's Tour is a classic chess problem where the objective is to move a knight to every square on a chessboard exactly once. /// Finds the Knight's Tour starting from the specified position. /// /// # Arguments /// /// * `size_x` -...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/hamiltonian_cycle.rs
src/backtracking/hamiltonian_cycle.rs
//! This module provides functionality to find a Hamiltonian cycle in a directed or undirected graph. //! Source: [Wikipedia](https://en.wikipedia.org/wiki/Hamiltonian_path_problem) /// Represents potential errors when finding hamiltonian cycle on an adjacency matrix. #[derive(Debug, PartialEq, Eq)] pub enum FindHamil...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/backtracking/graph_coloring.rs
src/backtracking/graph_coloring.rs
//! This module provides functionality for generating all possible colorings of a undirected (or directed) graph //! given a certain number of colors. It includes the GraphColoring struct and methods //! for validating color assignments and finding all valid colorings. /// Represents potential errors when coloring on ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/lowest_common_ancestor.rs
src/graph/lowest_common_ancestor.rs
/* Note: We will assume that here tree vertices are numbered from 1 to n. If a tree is not enumerated that way or its vertices are not represented using numbers, it can trivially be converted using Depth First Search manually or by using `src/graph/graph_enumeration.rs` Here we implement two different algorithms: - ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/bellman_ford.rs
src/graph/bellman_ford.rs
use std::collections::BTreeMap; use std::ops::Add; use std::ops::Neg; type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>; // performs the Bellman-Ford algorithm on the given graph from the given start // the graph is an undirected graph // // if there is a negative weighted loop it returns None // else it returns a map ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/prufer_code.rs
src/graph/prufer_code.rs
use std::collections::{BTreeMap, BTreeSet, BinaryHeap}; type Graph<V> = BTreeMap<V, Vec<V>>; pub fn prufer_encode<V: Ord + Copy>(tree: &Graph<V>) -> Vec<V> { if tree.len() <= 2 { return vec![]; } let mut result: Vec<V> = Vec::with_capacity(tree.len() - 2); let mut queue = BinaryHeap::new(); ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/ford_fulkerson.rs
src/graph/ford_fulkerson.rs
//! The Ford-Fulkerson algorithm is a widely used algorithm to solve the maximum flow problem in a flow network. //! //! The maximum flow problem involves determining the maximum amount of flow that can be sent from a source vertex to a sink vertex //! in a directed weighted graph, subject to capacity constraints on th...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/astar.rs
src/graph/astar.rs
use std::{ collections::{BTreeMap, BinaryHeap}, ops::Add, }; use num_traits::Zero; type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>; #[derive(Clone, Debug, Eq, PartialEq)] struct Candidate<V, E> { estimated_weight: E, real_weight: E, state: V, } impl<V: Ord + Copy, E: Ord + Copy> PartialOrd for Ca...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/detect_cycle.rs
src/graph/detect_cycle.rs
use std::collections::{HashMap, HashSet, VecDeque}; use crate::data_structures::{graph::Graph, DirectedGraph, UndirectedGraph}; pub trait DetectCycle { fn detect_cycle_dfs(&self) -> bool; fn detect_cycle_bfs(&self) -> bool; } // Helper function to detect cycle in an undirected graph using DFS graph traversal...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/graph_enumeration.rs
src/graph/graph_enumeration.rs
use std::collections::BTreeMap; type Graph<Vertex> = BTreeMap<Vertex, Vec<Vertex>>; /* This function creates a graph with vertices numbered from 1 to n for any input `Graph<V>`. The result is in the form of Vec<Vec<usize> to make implementing other algorithms on the graph easier and help with performance. We expect ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/tarjans_ssc.rs
src/graph/tarjans_ssc.rs
pub struct Graph { n: usize, adj_list: Vec<Vec<usize>>, } impl Graph { pub fn new(n: usize) -> Self { Self { n, adj_list: vec![vec![]; n], } } pub fn add_edge(&mut self, u: usize, v: usize) { self.adj_list[u].push(v); } } pub fn tarjan_scc(graph:...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/dinic_maxflow.rs
src/graph/dinic_maxflow.rs
use std::collections::VecDeque; use std::ops::{Add, AddAssign, Neg, Sub, SubAssign}; // We assume that graph vertices are numbered from 1 to n. /// Adjacency matrix type Graph = Vec<Vec<usize>>; /// We assume that T::default() gives "zero" flow and T supports negative values pub struct FlowEdge<T> { pub sink: us...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/centroid_decomposition.rs
src/graph/centroid_decomposition.rs
type Adj = [Vec<usize>]; const IN_DECOMPOSITION: u64 = 1 << 63; /// Centroid Decomposition for a tree. /// /// Given a tree, it can be recursively decomposed into centroids. Then the /// parent of a centroid `c` is the previous centroid that splitted its connected /// component into two or more components. It can be ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/two_satisfiability.rs
src/graph/two_satisfiability.rs
use super::strongly_connected_components::StronglyConnectedComponents as SCCs; pub type Condition = (i64, i64); type Graph = Vec<Vec<usize>>; #[inline] fn variable(var: i64) -> usize { if var < 0 { (((-var) << 1) + 1) as usize } else { (var << 1) as usize } } /// Returns an assignment tha...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/floyd_warshall.rs
src/graph/floyd_warshall.rs
use num_traits::Zero; use std::collections::BTreeMap; use std::ops::Add; type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>; /// Performs the Floyd-Warshall algorithm on the input graph.\ /// The graph is a weighted, directed graph with no negative cycles. /// /// Returns a map storing the distance from each node to all ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/prim.rs
src/graph/prim.rs
use std::cmp::Reverse; use std::collections::{BTreeMap, BinaryHeap}; use std::ops::Add; type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>; fn add_edge<V: Ord + Copy, E: Ord + Add + Copy>(graph: &mut Graph<V, E>, v1: V, v2: V, c: E) { graph.entry(v1).or_default().insert(v2, c); graph.entry(v2).or_default().insert...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/depth_first_search.rs
src/graph/depth_first_search.rs
use std::collections::HashSet; use std::collections::VecDeque; // Perform a Depth First Search Algorithm to find a element in a graph // // Return a Optional with a vector with history of vertex visiteds // or a None if the element not exists on the graph pub fn depth_first_search(graph: &Graph, root: Vertex, objectiv...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/dijkstra.rs
src/graph/dijkstra.rs
use std::collections::{BTreeMap, BTreeSet}; use std::ops::Add; type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>; // performs Dijsktra's algorithm on the given graph from the given start // the graph is a positively-weighted directed graph // // returns a map that for each reachable vertex associates the distance and th...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/mod.rs
src/graph/mod.rs
mod astar; mod bellman_ford; mod bipartite_matching; mod breadth_first_search; mod centroid_decomposition; mod decremental_connectivity; mod depth_first_search; mod depth_first_search_tic_tac_toe; mod detect_cycle; mod dijkstra; mod dinic_maxflow; mod disjoint_set_union; mod eulerian_path; mod floyd_warshall; mod ford_...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/breadth_first_search.rs
src/graph/breadth_first_search.rs
use std::collections::HashSet; use std::collections::VecDeque; /// Perform a breadth-first search on Graph `graph`. /// /// # Parameters /// /// - `graph`: The graph to search. /// - `root`: The starting node of the graph from which to begin searching. /// - `target`: The target node for the search. /// /// # Returns ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/kosaraju.rs
src/graph/kosaraju.rs
// Kosaraju algorithm, a linear-time algorithm to find the strongly connected components (SCCs) of a directed graph, in Rust. pub struct Graph { vertices: usize, adj_list: Vec<Vec<usize>>, transpose_adj_list: Vec<Vec<usize>>, } impl Graph { pub fn new(vertices: usize) -> Self { Graph { ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/minimum_spanning_tree.rs
src/graph/minimum_spanning_tree.rs
//! This module implements Kruskal's algorithm to find the Minimum Spanning Tree (MST) //! of an undirected, weighted graph using a Disjoint Set Union (DSU) for cycle detection. use crate::graph::DisjointSetUnion; /// Represents an edge in the graph with a source, destination, and associated cost. #[derive(Debug, Par...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/lee_breadth_first_search.rs
src/graph/lee_breadth_first_search.rs
use std::collections::VecDeque; // All four potential movements from a cell are listed here. fn validate(matrix: &[Vec<i32>], visited: &[Vec<bool>], row: isize, col: isize) -> bool { // Check if it is possible to move to the position (row, col) from the current cell. let (row, col) = (row as usize, col as usi...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/decremental_connectivity.rs
src/graph/decremental_connectivity.rs
use std::collections::HashSet; /// A data-structure that, given a forest, allows dynamic-connectivity queries. /// Meaning deletion of an edge (u,v) and checking whether two vertecies are still connected. /// /// # Complexity /// The preprocessing phase runs in O(n) time, where n is the number of vertecies in the fore...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/strongly_connected_components.rs
src/graph/strongly_connected_components.rs
/* Tarjan's algorithm to find Strongly Connected Components (SCCs): It runs in O(n + m) (so it is optimal) and as a by-product, it returns the components in some (reverse) topologically sorted order. We assume that graph is represented using (compressed) adjacency matrix and its vertices are numbered from 1 to n. If t...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/eulerian_path.rs
src/graph/eulerian_path.rs
//! This module provides functionality to find an Eulerian path in a directed graph. //! An Eulerian path visits every edge exactly once. The algorithm checks if an Eulerian //! path exists and, if so, constructs and returns the path. use std::collections::LinkedList; /// Finds an Eulerian path in a directed graph. /...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/bipartite_matching.rs
src/graph/bipartite_matching.rs
// Adjacency List use std::collections::VecDeque; type Graph = Vec<Vec<usize>>; pub struct BipartiteMatching { pub adj: Graph, pub num_vertices_grp1: usize, pub num_vertices_grp2: usize, // mt1[i] = v is the matching of i in grp1 to v in grp2 pub mt1: Vec<i32>, pub mt2: Vec<i32>, pub used: ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/topological_sort.rs
src/graph/topological_sort.rs
use std::collections::HashMap; use std::collections::VecDeque; use std::hash::Hash; #[derive(Debug, Eq, PartialEq)] pub enum TopoligicalSortError { CycleDetected, } type TopologicalSortResult<Node> = Result<Vec<Node>, TopoligicalSortError>; /// Given a directed graph, modeled as a list of edges from source to de...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/heavy_light_decomposition.rs
src/graph/heavy_light_decomposition.rs
/* Heavy Light Decomposition: It partitions a tree into disjoint paths such that: 1. Each path is a part of some leaf's path to root 2. The number of paths from any vertex to the root is of O(lg(n)) Such a decomposition can be used to answer many types of queries about vertices or edges on a particular path. It is ofte...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/depth_first_search_tic_tac_toe.rs
src/graph/depth_first_search_tic_tac_toe.rs
/* Tic-Tac-Toe Depth First Search Rust Demo Copyright 2021 David V. Makray 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...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/graph/disjoint_set_union.rs
src/graph/disjoint_set_union.rs
//! This module implements the Disjoint Set Union (DSU), also known as Union-Find, //! which is an efficient data structure for keeping track of a set of elements //! partitioned into disjoint (non-overlapping) subsets. /// Represents a node in the Disjoint Set Union (DSU) structure which /// keep track of the parent...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/relu.rs
src/math/relu.rs
//Rust implementation of the ReLU (rectified linear unit) activation function. //The formula for ReLU is quite simple really: (if x>0 -> x, else -> 0) //More information on the concepts of ReLU can be found here: //https://en.wikipedia.org/wiki/Rectifier_(neural_networks) //The function below takes a reference to a mu...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/exponential_linear_unit.rs
src/math/exponential_linear_unit.rs
//! # Exponential Linear Unit (ELU) Function //! //! The `exponential_linear_unit` function computes the Exponential Linear Unit (ELU) values of a given vector //! of f64 numbers with a specified alpha parameter. //! //! The ELU activation function is commonly used in neural networks as an alternative to the Leaky ReLU...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/average.rs
src/math/average.rs
#[doc = "# Average Mean, Median, and Mode, in mathematics, the three principal ways of designating the average value of a list of numbers. The arithmetic mean is found by adding the numbers and dividing the sum by the number of numbers in the list. This is what is most often meant by an average. The median is the middl...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/interquartile_range.rs
src/math/interquartile_range.rs
// Author : cyrixninja // Interquartile Range : An implementation of interquartile range (IQR) which is a measure of statistical // dispersion, which is the spread of the data. // Wikipedia Reference : https://en.wikipedia.org/wiki/Interquartile_range use std::cmp::Ordering; pub fn find_media...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/quadratic_residue.rs
src/math/quadratic_residue.rs
/// Cipolla algorithm /// /// Solving quadratic residue problem: /// x^2 = a (mod p) , p is an odd prime /// with O(M*log(n)) time complexity, M depends on the complexity of complex numbers multiplication. /// /// Wikipedia reference: https://en.wikipedia.org/wiki/Cipolla%27s_algorithm /// When a is the primitive r...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/decimal_to_fraction.rs
src/math/decimal_to_fraction.rs
pub fn decimal_to_fraction(decimal: f64) -> (i64, i64) { // Calculate the fractional part of the decimal number let fractional_part = decimal - decimal.floor(); // If the fractional part is zero, the number is already an integer if fractional_part == 0.0 { (decimal as i64, 1) } else { ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/perfect_numbers.rs
src/math/perfect_numbers.rs
pub fn is_perfect_number(num: usize) -> bool { let mut sum = 0; for i in 1..num - 1 { if num.is_multiple_of(i) { sum += i; } } num == sum } pub fn perfect_numbers(max: usize) -> Vec<usize> { let mut result: Vec<usize> = Vec::new(); // It is not known if there are ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/field.rs
src/math/field.rs
use core::fmt; use std::hash::{Hash, Hasher}; use std::ops::{Add, Div, Mul, Neg, Sub}; /// A field /// /// <https://en.wikipedia.org/wiki/Field_(mathematics)> pub trait Field: Neg<Output = Self> + Add<Output = Self> + Sub<Output = Self> + Mul<Output = Self> + Div<Output = Self> + Eq + Copy ...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/doomsday.rs
src/math/doomsday.rs
const T: [i32; 12] = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]; pub fn doomsday(y: i32, m: i32, d: i32) -> i32 { let y = if m < 3 { y - 1 } else { y }; (y + y / 4 - y / 100 + y / 400 + T[(m - 1) as usize] + d) % 7 } pub fn get_week_day(y: i32, m: i32, d: i32) -> String { let day = doomsday(y, m, d); let da...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/square_pyramidal_numbers.rs
src/math/square_pyramidal_numbers.rs
// https://en.wikipedia.org/wiki/Square_pyramidal_number // 1² + 2² + ... = ... (total) pub fn square_pyramidal_number(n: u64) -> u64 { n * (n + 1) * (2 * n + 1) / 6 } #[cfg(test)] mod tests { use super::*; #[test] fn test0() { assert_eq!(0, square_pyramidal_number(0)); assert_eq!(1,...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/gaussian_elimination.rs
src/math/gaussian_elimination.rs
// Gaussian Elimination of Quadratic Matrices // Takes an augmented matrix as input, returns vector of results // Wikipedia reference: augmented matrix: https://en.wikipedia.org/wiki/Augmented_matrix // Wikipedia reference: algorithm: https://en.wikipedia.org/wiki/Gaussian_elimination pub fn gaussian_elimination(matri...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/random.rs
src/math/random.rs
/* Permuted Congruential Generator https://en.wikipedia.org/wiki/Permuted_congruential_generator Note that this is _NOT_ intended for serious applications. Use this generator at your own risk and only use your own values instead of the default ones if you really know what you are doing. */ pub struct PCG32 { stat...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/bell_numbers.rs
src/math/bell_numbers.rs
use num_bigint::BigUint; use num_traits::{One, Zero}; use std::sync::RwLock; /// Returns the number of ways you can select r items given n options fn n_choose_r(n: u32, r: u32) -> BigUint { if r == n || r == 0 { return One::one(); } if r > n { return Zero::zero(); } // Any combina...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false
TheAlgorithms/Rust
https://github.com/TheAlgorithms/Rust/blob/38024b01c29eb05f733d480f88f19f0c06922a85/src/math/elliptic_curve.rs
src/math/elliptic_curve.rs
use std::collections::HashSet; use std::fmt; use std::hash::{Hash, Hasher}; use std::ops::{Add, Neg, Sub}; use crate::math::field::{Field, PrimeField}; use crate::math::quadratic_residue::legendre_symbol; /// Elliptic curve defined by `y^2 = x^3 + Ax + B` over a prime field `F` of /// characteristic != 2, 3 /// /// T...
rust
MIT
38024b01c29eb05f733d480f88f19f0c06922a85
2026-01-04T15:37:39.002409Z
false