Expand description
§linked-markov
A minimal, thread-safe Markov chain implementation using reference-counted steps and weighted transitions.
§Features
- Generic over state type
T(must beEq + Copy + Hash + Debug) - Weighted transitions between states
- Deterministic and mutable walks
§Examples
use linked_markov::{Step, ToStep, walk};
use std::sync::Arc;
let step_false: ToStep<bool> = Arc::new(Step::new(false));
let step_true: ToStep<bool> = Arc::new(Step::new(true));
step_false.insert_transition(step_true.clone(), 3);
step_false.insert_transition(step_false.clone(), 1);
step_true.insert_transition(step_false.clone(), 3);
step_true.insert_transition(step_true.clone(), 1);
let path = walk(step_false, 100);
assert_eq!(path.len(), 100);Structs§
- Step
- A node in the Markov chain, holding a state and weighted transitions to other steps.
Functions§
- mut_
walk - Walk the Markov chain for a fixed number of steps, applying a function to each transition.
- walk
- Walk the Markov chain for a fixed number of steps, returning the visited states.
Type Aliases§
- ToStep
- A reference-counted pointer to a
Stepin the Markov chain.