Macro graphalgos::gph

source ·
macro_rules! gph {
    ( $($sub:tt),* ) => { ... };
}
Expand description

Function to check if the given vertex is present in the graph

Parameters

  1. label - Label of the vertex - type String

Return Type

Returns a boolean value.

true - if the vertex is present in the graph

false - if the vertex is not present in the graph

Example

if g.contains_vertex(String::from("A")){
    // Do something
}

Build an undirected graph

This macro can make both vertices and edges. For a vertex, simple pass a string literal to be that vertex’s label. For an edge, write a pattern of the form (str, i32, str) where the first and last element represent the label of a vertex, and the middle value is the edges weight.

Example

let G = gph!("A", "B", "C", ("A", 3, "C"), ("B", 7, "D"))

Notice that we do not need to list all vertices before adding edges for them, as shown in the last edge pattern.