Skip to content

Algorithms

nodus.algorithms runs graph algorithms over the current graph. Option shapes are loosely typed; typical inputs are source/target ids or node references and, where relevant, an optional edge-weight accessor. The descriptions below document inputs and outputs in prose rather than inventing concrete option keys.

Heavy algorithms can be offloaded to the compiled backend — see backend activation.

Find a shortest path through the graph. Inputs identify the source and target (by id or node reference); an optional edge-weight accessor lets you weight the search. Returns the path (its nodes/edges) found between the endpoints.

const path = nodus.algorithms.shortestPath({ /* source/target + options */ });

Try it live — pick a source and target to see the shortest path light up:

Shortest path (live) Open in new tab ↗

Returns whether the graph contains a cycle.

Returns the graph’s simple cycles.

Detects a cycle in the graph and reports it.

if (nodus.algorithms.hasCycle()) {
const cycles = nodus.algorithms.getAllSimpleCycles();
}

Computes a minimum spanning tree of the graph, honoring an edge-weight accessor when provided. Returns the tree’s edges.

const mst = nodus.algorithms.minimumSpanningTree();

Depth-first traversal from a starting node.

Breadth-first traversal from a starting node.

Both take a start node (by id or reference) and return the elements in traversal order.

const order = nodus.algorithms.bfs({ /* start node + options */ });

Try it live — pick a start node and watch BFS and DFS visit order unfold:

BFS & DFS (live) Open in new tab ↗

Computes betweenness centrality for the graph’s nodes, returning a centrality value per node.

const centrality = nodus.algorithms.betweenness();

Try it live — node size and colour scale with betweenness centrality:

Betweenness (live) Open in new tab ↗

Returns the smallest circle that encloses the given nodes (its center and radius).

Packs elements into circles. Inputs configure the set to pack and its layout; returns the packed result.

Applies a fish-eye expansion (a focus-plus-context magnification) around a focal region.

const circle = nodus.algorithms.getMinimumEnclosingCircle(nodus.getNodes());

Try it live — pack nodes into nested circles:

Circle packing (live) Open in new tab ↗

Try it live — move the focus to magnify nodes near the cursor:

Fisheye focus (live) Open in new tab ↗