nodify

Crates.ionodify
lib.rsnodify
version0.1.0
created_at2025-07-10 12:04:34.804153+00
updated_at2025-07-10 12:04:34.804153+00
descriptionA small crate providing utilies to explore graph (boosted by Rayon)
homepage
repositoryhttps://github.com/beatussum/nodify
max_upload_size
id1746254
size101,283
Mattéo Rossillol‑‑Laruelle (beatussum)

documentation

README

nodify

Table of contents

Description

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::*

Example

//! 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.

Building

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.

Features

  • rayon: to support algorithms using Rayon.

Using as a dependency

cargo add nodify

Building from source

Dependencies

  • The Rust toolchain (build)
  • Git (build)

Building process

  1. Clone this repository.

    git clone "https://github.com/beatussum/nodify.git"
    
  2. Build the crate.

    cargo build -r # (-r for release build), or
    cargo build -r -F <features> # if you want to set non default features
    

Licenses

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.

Commit count: 0

cargo fmt