Skip to content

@graphty/algorithms / index / indexed / topologicalSort

Function: topologicalSort() ​

topologicalSort(g, options?): U32 | null

Defined in: indexed/dfs.ts:242

Topological order of a directed graph: reverse DFS post-order, roots taken in index order and neighbours in row order unless options.arcOrder gives another.

Parameters ​

g ​

AdjacencyView

A directed adjacency

options? ​

ArcOrderOption = {}

The neighbour order

Returns ​

U32 | null

The node indices in topological order, or null when the graph has a cycle

Throws ​

Error when the graph is undirected