Macro hypergraph

Source
macro_rules! hypergraph {
    (
        let mut $graph:ident: $H:ty {
            nodes: {$($nodes:tt)*};
            edges: {$($edges:tt)*};
        }
    ) => { ... };
    (
        $graph:ident {
            nodes: {$($nodes:tt)*};
            edges: {$($edges:tt)*};
        }
    ) => { ... };
}
Expand description

the [hypergraph] macro works to aide the in the creation of hypergraphs by allowing users to define nodes and edges in a hypergraph in a more declarative way.

§Example

§Basic Usage

The hypergraph macro allows you to define nodes and edges in a hypergraph

use hypergraphx::prelude::*;
// initialize a new undirected hypergraph
let mut graph = UndirectedHypergraph::<usize, usize>::new();
// use the macro to insert nodes and edges into the graph
hypergraph! {
    graph {
        nodes: {
            let v0 = 0;
            let v1 = 1;
            let v2 = 10;
        };
        edges: {
            let e0: [v0, v1];
            [v0, v1, v2] = 10;
        };
    }
}

or

use hypergraph::prelude::*;

// use the macro to initialize a new hypergraph, then insert nodes and edges
hypergraph! {
    let mut graph: UndirectedHypergraph<usize, usize> {
        nodes: {
            let v0 = 0;
            let v1 = 1;
            let v2 = 2;
        };
        edges: {
            let e0: [v0, v1] = 5;
            let e1: [v0, v2] = 7;
            [v0, v1, v2] = 10;
        };
    }
}