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
generate_complete- Complete graphs where every node connects to every other nodegenerate_path- Linear chains of connected nodesgenerate_cycle- Circular chains of nodesgenerate_grid- 2D grid structures with optional periodic boundariesgenerate_star- Star topologies with one central hubgenerate_tree- Tree structures with specified branching and depthgenerate_barabasi_albert- Scale-free networks using preferential attachment
§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(¶ms).unwrap();
assert_eq!(graph.node_count(), 4);
assert_eq!(graph.edge_count(), 6); // Complete graph: n*(n-1)/2 edgesFunctions§
- 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§
- Generator
Fn - Function signature for graph generator functions.