graph-algorithms-rs

Crates.iograph-algorithms-rs
lib.rsgraph-algorithms-rs
version0.1.9
sourcesrc
created_at2024-10-24 16:55:47.495602
updated_at2024-11-05 21:42:32.671152
descriptionA collection of graph algorithms.
homepage
repositoryhttps://github.com/slavik-pastushenko/graph-algorithms-rs
max_upload_size
id1421541
size35,025
Slavik (slavik-pastushenko)

documentation

https://docs.rs/graph-algorithms-rs

README

Graph Algorithms

A collection of graph algorithms implemented in Rust. This repository aims to provide efficient and easy-to-understand implementations of various graph algorithms for educational purposes and practical use.

Contributions are welcome to expand the set of algorithms and improve existing implementations.

Reference implementation

test release docs crate downloads codecov License

Algorithm Description Example
Dijkstra's Finds the shortest path from a starting node to all other nodes in a weighted graph. It uses a priority queue to efficiently select the next node with the smallest distance. Dijkstra's
Bellman-Ford Computes shortest paths from a single source vertex to all of the other vertices in a weighted digraph. It can handle graphs with negative weight edges. Bellman-Ford
Floyd-Warshall Finds shortest paths between all pairs of vertices in a weighted graph. It can handle graphs with negative weights but no negative weight cycles. Floyd-Warshall

A* Algorithm (TODO)

A* is a pathfinding and graph traversal algorithm that is often used in many fields of computer science due to its completeness, optimality, and optimal efficiency.

Breadth-First Search (BFS) (TODO)

BFS explores the graph level by level, starting from a given node. It is used for finding the shortest path in an unweighted graph.

Depth-First Search (DFS) (TODO)

DFS explores as far as possible along each branch before backtracking. It is used for pathfinding and topological sorting.

Safety

This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.

Usage

The examples directory contains example implementations of various graph algorithms:

use graph_algorithms::{DijkstraAlgorithm, GraphAlgorithm};

Features

This crate provides optional features for different algorithms.

By default, all features are enabled. You can customize the features when adding the dependency in your Cargo.toml:

[dependencies]
graph-algorithms-rs = { version = "x.x.x", default-features = false, features = ["dijkstra"] }

For a detailed list of available algorithms, refer to the Reference implementation section.

Contributing

Build the application:

cargo build

Test the application:

cargo test

Run clippy:

cargo clippy --all-targets --all-features --no-deps -- -D warnings

Run lint:

cargo fmt

Generate documentation in HTML format:

cargo doc --open
Commit count: 25

cargo fmt