Macro hyperedge

Source
macro_rules! hyperedge {
    ($src:ident {
        $($(let $edge:ident:)? [$($var:ident),*] = $w:expr);* $(;)?
    }) => { ... };
    (@new $src:ident.$edge:ident: [$($var:ident),*] = $w:expr) => { ... };
    (@new $src:ident [$($var:ident),*] = $w:expr) => { ... };
    ($src:ident {
        $($(let $edge:ident:)? ([$($var:ident),*] -> [$($dst:ident),*]) = $w:expr);* $(;)?
    }) => { ... };
    (@new $src:ident.$edge:ident: ([$($var:ident),*] -> [$($dst:ident),*]) = $w:expr) => { ... };
    (@new $src:ident ([$($var:ident),*] -> [$($dst:ident),*]) = $w:expr) => { ... };
}
Expand description

The hyperedge macro streamlines the definition of hyperedges in a hypergraph.

§Usage

The macro requires that you to pass a mutable reference to some hypergraph by first defining the ident of the associated graph. Once declared, hyperedges are defined as let statement within a block, where each statement defines a hyperedge by its name and the vertices it connects. Instead of specifying the type of hyperedge, a slice of node indices is used to define the edge consituents.

Edges may be declared without a binding as well.

hyperedge! {
    ${graph} {
        let ${edge_name}: [${vertex1}, ${vertex2}, ...] = ${weight};
    },
    ${graph} {
        [${vertex1}, ${vertex2}, ...] = ${weight};
    }
}