Module generators

Source
Expand description

§Graph Generators

This module provides built-in graph generators for creating common graph topologies. Generators are invoked using the generate statement in GGL programs and can create various types of graph structures with customizable parameters.

§Available Generators

§Usage in GGL

Generators are invoked using the generate statement:

generate complete {
    nodes: 5;
    prefix: "vertex";
}

§Common Parameters

Most generators support these parameters:

  • nodes - Number of nodes to generate (required for most generators)
  • prefix - Node name prefix (optional, default: “n”)
  • directed - Whether edges should be directed (optional, default: false)

§Examples

use graph_generation_language::generators::generate_complete;
use graph_generation_language::types::MetadataValue;
use std::collections::HashMap;

let mut params = HashMap::new();
params.insert("nodes".to_string(), MetadataValue::Integer(4));
params.insert("prefix".to_string(), MetadataValue::String("vertex".to_string()));

let graph = generate_complete(&params).unwrap();
assert_eq!(graph.node_count(), 4);
assert_eq!(graph.edge_count(), 6); // Complete graph: n*(n-1)/2 edges

Functions§

generate_barabasi_albert
generate_complete
Generates a complete graph where every node is connected to every other node.
generate_cycle
Generates a cycle graph (circular chain of nodes).
generate_grid
generate_path
Generates a path graph (linear chain of connected nodes).
generate_star
generate_tree
get_generator
Returns the generator function for the given name.

Type Aliases§

GeneratorFn
Function signature for graph generator functions.