Data and Math

vdepgraph

Puts dependencies in order, and catches the cycles that can’t be ordered.

Released v1.0.0 · 2026-09-28
Import
use "stdlib/depgraph.ven"

Puts a set of dependencies in order with a topological sort, and finds the cycles that cannot be ordered, built on Venutian's own map, set and list builtins. It is a small, general purpose graph resolver, useful for anything from build steps to package installation order.

vdepgraph.ven
print DepGraph(new_map())
Reference (5 functions)

API reference

depgraph_new()

Builds an empty DepGraph with no registered nodes.

depgraph_new()

depgraph_add(graph, name, depends_on)

Registers name in graph as depending on every name in depends_on.

g = depgraph_new()
depgraph_add(g, "app", ["lib", "utils"])
map_keys(g.nodes)

resolve_order(graph)

Gives back every name in graph in a valid topological order.

g = depgraph_new()
depgraph_add(g, "app", ["lib", "utils"])
depgraph_add(g, "lib", ["utils"])
resolve_order(g)

has_cycle(graph)

Tests whether graph has a dependency cycle, without building the order.

g = depgraph_new()
depgraph_add(g, "a", ["b"])
depgraph_add(g, "b", ["a"])
has_cycle(g)

depgraph_index_of(order, name)

Gives back the index of name within a resolve_order result.

g = depgraph_new()
depgraph_add(g, "app", ["lib", "utils"])
depgraph_index_of(resolve_order(g), "utils")

Get notified when vdepgraph changes

Get notified about

New versions and security advisories.

New and updated packages, once a day.

News on the math model built in Venutian.