hypernode

Macro hypernode 

Source
macro_rules! hypernode {
    ($src:ident { $(let $var:ident = $w:expr);* $(;)? }) => { ... };
    (@new $src:ident.$var:ident = $w:expr) => { ... };
}
Expand description

the [hypernode] macro streamlines the process of inserting nodes into 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, hypernodes are defined as let statement within a block, where each statement defines the identifier of a node. Optionally, a weight may be specified for the hypernode by appending = <weight>.

hypernode! {
    $graph: {
        let $var:ident $(= $w:expr)?;
    }
}

§Example

use rshyper::HyperMap;
// initialize a new, undirected hypergraph
let mut graph = HyperMap::<usize, usize>::undirected();
// use the macro to insert nodes into the graph
rshyper::hypernode! {
    graph {
        let v0;
        let v1;
        let v2;
        let v3 = 1;
        let v4 = 2;
        let v5 = 3;
    }
 }