topological-sort-group
Version:
Topological sorting and cycle detection. Optional grouping for parallel processing
25 lines (24 loc) • 677 B
TypeScript
export interface GraphOptions {
path?: string;
}
export declare const SortMode: {
readonly Group: 1;
readonly Flat: 2;
};
export type Cycle = Key[];
export type Node<T extends Key> = Value<T> | Key;
export interface SortResult<T extends Key> {
nodes: Node<T>[][];
cycles: Cycle[];
}
export type Key = string | number | symbol;
export type NestedValue<T> = Record<Key, T>;
export type Value<T extends Key> = T | NestedValue<T | NestedValue<T>>;
export type Counter<T extends Key, X> = Record<T, X>;
export type NodeRecord<T extends Key> = {
value: Value<T>;
edges: T[];
};
export type NodeRecords<T extends Key> = {
[key in T]: NodeRecord<T>;
};