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