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.
Paths
shortestPath(opts)
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:
Cycles
hasCycle(opts?) -> boolean
Returns whether the graph contains a cycle.
getAllSimpleCycles(opts?)
Returns the graph’s simple cycles.
detectCycle(opts?)
Detects a cycle in the graph and reports it.
if (nodus.algorithms.hasCycle()) { const cycles = nodus.algorithms.getAllSimpleCycles();}Spanning tree
minimumSpanningTree(opts?)
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();Traversals
dfs(opts)
Depth-first traversal from a starting node.
bfs(opts)
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:
Centrality
betweenness(opts?)
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:
Geometry and packing
getMinimumEnclosingCircle(nodes)
Returns the smallest circle that encloses the given nodes (its center and radius).
circlePack(opts)
Packs elements into circles. Inputs configure the set to pack and its layout; returns the packed result.
fishEyeExpand(opts)
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:
Try it live — move the focus to magnify nodes near the cursor: