heapless_graphs 0.2.3

Implementation of composable graphs for no_alloc environments
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// SPDX-License-Identifier: Apache-2.0

use heapless_graphs::{
    algorithms::bfs, containers::queues::CircularQueue, edgelist::edge_list::EdgeList,
};

fn main() {
    // Create a simple graph: 0->1, 0->2, 1->3, 2->3
    let graph = EdgeList::<8, _, _>::new([(0, 1), (0, 2), (1, 3), (2, 3)]);
    let mut visited = [false; 10];
    let queue = CircularQueue::<usize, 16>::new();

    println!("BFS traversal starting from node 0:");
    bfs(&graph, 0, visited.as_mut_slice(), queue, &mut |x| {
        println!("visited: {}", x)
    })
    .unwrap();
}