@types/toposort
Version:
TypeScript definitions for toposort
45 lines (39 loc) • 1.74 kB
Markdown
# Installation
> `npm install --save @types/toposort`
# Summary
This package contains type definitions for toposort (https://github.com/marcelklehr/toposort).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/toposort.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/toposort/index.d.ts)
````ts
/**
* @param edges An array of directed edges describing a graph. An edge looks
* like this: `[node1, node2]` (vertices needn't be strings but can
* be of any type).
* @returns a list of vertices, sorted from "start" to "end"
* @throws if there are any cycles in the graph
*/
declare function toposort<T = string>(edges: ReadonlyArray<[T, T | undefined]>): T[];
declare namespace toposort {
/**
* This is a convenience method that allows you to define nodes that may or
* may not be connected to any other nodes. The ordering of unconnected
* nodes is not defined.
* @param nodes An array of nodes
* @param edges An array of directed edges. You don't need to mention all
* `nodes` here.
* @returns a list of vertices, sorted from "start" to "end"
* @throws if there are any cycles in the graph
*/
function array<T = string>(
nodes: readonly T[],
edges: ReadonlyArray<[T, T | undefined]>,
): T[];
}
export = toposort;
````
### Additional Details
* Last updated: Mon, 20 Nov 2023 23:36:24 GMT
* Dependencies: none
# Credits
These definitions were written by [Daniel Byrne](https://github.com/danwbyrne), [Prokop Simek](https://github.com/prokopsimek), and [Emily Marigold Klassen](https://github.com/forivall).