I’ve been working on zigraph, a modular DAG layout engine. It started as a port of my rust library ascii-dag, but has evolved into something more ambitious i.e. graph layout layout infrastructure where each component can be used independently
- Currently supports: Sugiyama layout (Median Heuristic, Barycenter) with Brandes-Kopf positioning
- output supported are internal IR, terminal, SVG, JSON
- BYOA (Bring your own Algorithm) - trying to be modular as much as I can
Examples:
usage:
const std = @import("std");
const zigraph = @import("zigraph");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
// 1. Build the graph
var graph = zigraph.Graph.init(allocator);
defer graph.deinit();
try graph.addNode(1, "Root");
try graph.addNode(2, "Task A");
try graph.addNode(3, "Task B");
try graph.addNode(4, "Output");
try graph.addEdge(1, 2);
try graph.addEdge(1, 3);
try graph.addEdge(2, 4);
try graph.addEdge(3, 4);
// 2. Render to Terminal (with colored edges!)
const TUI = try zigraph.render(&graph, allocator, .{
.edge_palette = &zigraph.colors.ansi_dark,
});
defer allocator.free(TUI);
std.debug.print("{s}\n", .{TUI});
// 3. Or export directly to SVG
// const SVG = try zigraph.svg.render(&graph, allocator, .{ ... });
}
This is a v0.1 release, so things might be a bit rough. I’m open to all feedback and PRs to help smooth it out
