| Crates.io | nodify |
| lib.rs | nodify |
| version | 0.1.0 |
| created_at | 2025-07-10 12:04:34.804153+00 |
| updated_at | 2025-07-10 12:04:34.804153+00 |
| description | A small crate providing utilies to explore graph (boosted by Rayon) |
| homepage | |
| repository | https://github.com/beatussum/nodify |
| max_upload_size | |
| id | 1746254 |
| size | 101,283 |
This small crate aims to provide a easy way to apply computations on problem using graph to be resolved.
For the time being, only ContainsAny process is supported allowing to find any node verifying a given predicate. This process is implemented using DFS with a sequential variant and a parallel one.
With this crate, you just need to implement the Node trait with the outgoing() method to be able to apply process.
All processes and process implementations are stored under nodify::process::*
//! Nodify the Fibonnacci sequence
use nodify::prelude::*;
use std::iter::once;
/// A node representing the current state of the sequence
///
/// This trait need to be [`Eq`] and [`Hash`] due to the [`DFS`] process implementation used. It
/// needs also to be [`Copy`] in order to be used without reference.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct FiboNode {
/// The previous term value
pub previous: u64,
/// The current term value
pub current: u64,
}
impl FiboNode {
/// Get the first [node](FiboNode) of the sequence
///
/// It corresponds to the two first values of the sequence.
pub fn first() -> Self {
Self {
previous: 0,
current: 1,
}
}
}
impl Node for FiboNode {
fn outgoing(self) -> impl Iterator<Item = Self> {
let next = Self {
previous: self.current,
current: self.previous + self.current,
};
once(next)
}
}
fn main() {
let first = FiboNode::first();
let result = first
.process::<DFS<_>>()
.contains_any(|FiboNode { current, .. }| current == 610);
println!("{first:?} => {result}");
}
You can consult this example at examples/fibonacci.rs.
First, you need to have a Rust toolchain installed. You can follow the instructions at this page. If you are a GNU/Linux user, it should be included in the official repositories of your favorite distribution. This project is based on the Cargo package manager.
rayon: to support algorithms using Rayon.cargo add nodify
Clone this repository.
git clone "https://github.com/beatussum/nodify.git"
Build the crate.
cargo build -r # (-r for release build), or
cargo build -r -F <features> # if you want to set non default features
As explained above, the code of this software is licensed under GPL-3 or any later version.
Details of the rights applying to the various third-party files are described in the copyright file in the Debian debian/copyright file format.