Skip to content

@graphty/algorithms / index / topologicalSort

Function: topologicalSort() ​

topologicalSort(graph): NodeId[] | null

Defined in: algorithms/traversal/dfs.ts:246

Topological sorting using DFS (for directed acyclic graphs)

Parameters ​

graph ​

Graph

The directed acyclic graph to sort

Returns ​

NodeId[] | null

Array of node IDs in topological order, or null if graph has cycles