TopoSort - Topological Sort on Dependency Graph TopoSort is a highly efficient Zig library for performing topological sort on dependency graph. This small library is packed with the following features: Building dependency graph from dependency data. Performing topological sort on the dependency graph. Generating dependence-free subsets for parallel processing. Cycle detection and cycle reporting. Support different node types. Content Installation Go to the Releases page. Pick a release to add to your project. Identify the file asset URL for the release version. E.g. https://github.com/williamw520/toposort/archive/refs/tags/1.0.2.tar.gz Use zig fetch to add the TopoSort package to your Zig project. Run the following command to fetch the TopoSort package: zig fetch --save https://github.com/williamw520/toposort/archive/refs/tags/ < VERSION > .tar.gz zig fetch updates your build.zig.zon file with the URL with file hash added in the .dependency section of the file. .{ .name = "my-project", ... .dependencies = .{ + .toposort = .{ + .url = "zig fetch https://github.com/williamw520/toposort/archive/refs/tags/<VERSION>.tar.gz", + .hash = "toposort-...", + }, }, } Update your build.zig with the lines for toposort. pub fn build(b: *std.Build) void { ... + const opts = .{ .target = target, .optimize = optimize }; + const toposort_module = b.dependency("toposort", opts).module("toposort"); ... const exe = b.addExecutable(.{ .name = "my_project", .root_module = exe_mod, }); + exe.root_module.addImport("toposort", toposort_module); The .addImport("toposort") call let you import the module into your Zig source files. const toposort = @import ( "toposort" ); Usage Usage typically follows the following steps in your Zig source file. Import const toposort = @import ( "toposort" ); const TopoSort = toposort . TopoSort ; const SortResult = toposort . SortResult ; Initialization and memory management. const T = usize ; // node data type var tsort = try TopoSort ( T ). init ( allocator ,...
First seen: 2025-04-01 18:47
Last seen: 2025-04-02 11:50