Expand description
§Graph Generation Language (GGL)
GGL is a domain-specific language for creating and manipulating graphs through a powerful, declarative syntax. It supports dynamic graph construction using variables and loops.
§Overview
GGL allows you to:
- Define graph structures using intuitive node and edge declarations.
- Use variables and loops to generate complex or repetitive patterns programmatically.
- Create common graph topologies with built-in generators.
- Apply transformation rules to modify graph structure.
- Export graphs in standard JSON format for visualization or further processing.
§Quick Example
graph dynamic_network {
// Declare variables
let prefix: string = "user_";
let count: int = 5;
// Create nodes in a loop
for i in 0..count {
node "{prefix}{i}" :person [id_num=i, status="active"];
}
// Create a chain of relationships
for i in 0..(count - 1) {
edge: "{prefix}{i}" -> "{prefix}{i+1}" [weight=0.5];
}
// Generate a star graph and connect it
generate star {
nodes: 5;
prefix: "service";
}
edge: "user_0" -- "service0";
}
§Features
- Dynamic Syntax: Supports variables and for-loops for programmatic graph construction.
- Declarative core: Intuitive node and edge declarations remain at the core.
- Built-in Generators: Create common graph structures (complete, path, cycle, grid, star, tree, scale-free).
- Transformation Rules: Apply pattern-based rules to modify graph structure.
- Rich Attributes: Support for typed nodes and edges with metadata.
- JSON Output: Export graphs in standard JSON format.
§More Examples
§Torus
This example generates a 2D torus by creating a grid of nodes and connecting them with wrap-around edges.
graph toroidal_mesh {
let rows = 10;
let cols = 10;
// Create the nodes
for i in 0..rows {
for j in 0..cols {
node n{i}_{j};
}
}
// Create the horizontal edges
for i in 0..rows {
for j in 0..cols {
let next_j = (j + 1) % cols;
edge: n{i}_{j} -> n{i}_{next_j};
}
}
// Create the vertical edges
for i in 0..rows {
for j in 0..cols {
let next_i = (i + 1) % rows;
edge: n{i}_{j} -> n{next_i}_{j};
}
}
}
§Getting Started
§Installation
Prerequisites:
- Rust 1.70 or later
- Cargo (comes with Rust)
Building from source:
git clone [https://github.com/ocasazza/graph-generation-language.git](https://github.com/ocasazza/graph-generation-language.git)
cd graph-generation-language
cargo build --release
Modules§
- generators
- Graph Generators
- parser
- GGL language parser and Abstract Syntax Tree (AST) definitions.
This module uses the
pest
library to parse GGL source code into a structured AST. - rules
- Transformation rule engine for graph manipulation.
- types
- Core data structures for representing graphs.
Structs§
- GGLEngine
- The main GGL engine for parsing and executing GGL programs.