Zog.Generator (Zog v0.1.0)

View Source

Generators for creating synthetic and random graphs.

Summary

Functions

Generates a Barabási-Albert scale-free random graph.

Generates an Erdős-Rényi random graph G(n, p).

Generates a 2D Grid / Lattice graph.

Generates a Watts-Strogatz small-world random graph.

Functions

barabasi_albert(n, m, opts \\ [])

@spec barabasi_albert(integer(), integer(), keyword()) :: Zog.SoA.t()

Generates a Barabási-Albert scale-free random graph.

Nodes are labeled from 0 to n-1. Starts with a clique of size m, then adds remaining nodes one by one, connecting them to m existing nodes with probability proportional to their degree.

Options

  • :kind - Graph kind, either :directed or :undirected (default).

erdos_renyi(n, p, opts \\ [])

@spec erdos_renyi(non_neg_integer(), float(), keyword()) :: Zog.SoA.t()

Generates an Erdős-Rényi random graph G(n, p).

Nodes are labeled from 0 to n-1. Each potential edge is present with probability p. Uses the linear-time Batagelj-Brandes algorithm for efficient generation of sparse graphs.

Options

  • :kind - Graph kind, either :directed or :undirected (default).

grid_2d(rows, cols, opts \\ [])

@spec grid_2d(integer(), integer(), keyword()) :: Zog.SoA.t()

Generates a 2D Grid / Lattice graph.

Nodes are labeled with tuples {row, col} where 0 <= row < rows and 0 <= col < cols.

Options

  • :kind - Graph kind, either :directed or :undirected (default).

watts_strogatz(n, k, beta, opts \\ [])

@spec watts_strogatz(integer(), integer(), float(), keyword()) :: Zog.SoA.t()

Generates a Watts-Strogatz small-world random graph.

Starts with a ring lattice of n nodes connected to k nearest neighbors, then rewires each edge with probability beta.

Options

  • :kind - Graph kind, either :directed or :undirected (default).