Skip to main content

Crate ogun

Crate ogun 

Source
Expand description

§Ogun

Spatial layout generation via sequential logit dynamics on potential games.

Given a weighted graph and a 2D spatial domain, Ogun places nodes and routes edges at a controllable optimization level. The inverse temperature β governs output character — from near-random (low β) to near-optimal (high β).

§Algorithm

for each agent in arrival order:
    1. EVAL_UTILITY  — score every valid grid position via potential Φ
    2. CHOOSE        — Boltzmann sample: P(p) ∝ exp(β · Φ(p))
    3. COMMIT        — place irrevocably, block footprint
    4. ROUTE         — BFS (Lee) to already-placed neighbors
score the completed layout

§Quick start

use ogun::*;

let graph = Graph {
    nodes: vec![
        Node { id: NodeId(0), radius: 1 },
        Node { id: NodeId(1), radius: 1 },
    ],
    edges: vec![Edge {
        id: EdgeId(0),
        src: NodeId(0),
        dst: NodeId(1),
        weight: 1.0,
    }],
};
let space = Space { width: 20, height: 20, obstacles: vec![] };
let config = OgunConfig { seed: 42, ..OgunConfig::default() };

let layout = generate(&graph, &space, &config);
assert!(layout.score > 0.0);

Structs§

Edge
A weighted edge connecting two nodes.
EdgeId
Type-safe edge index.
Graph
The graph of nodes and edges to lay out.
Grid
A 2D grid stored as a flat Vec<T> in row-major order.
Layout
The result of running the Ogun algorithm.
Node
A node (agent) to be placed in the layout.
NodeId
Type-safe node index.
OgunConfig
Algorithm parameters.
Pos
Grid coordinate (column, row).
Rect
An axis-aligned rectangle used for obstacles and keep-out zones.
Space
The 2D spatial domain: boundary dimensions and obstacle list.

Functions§

generate
Generate a spatial layout from a graph and spatial domain.