UNPKG

d3-dag

Version:

Layout algorithms for visualizing directed acylic graphs.

59 lines (58 loc) 1.88 kB
/** * a {@link TwolayerGreedy} that calls another {@link Twolayer} before greedily * swapping nodes to minimize crossings. * * @packageDocumentation */ import { Twolayer } from "."; /** * a {@link Twolayer} that greedily swaps nodes * * Create with {@link twolayerGreedy}. */ export interface TwolayerGreedy<Op extends Twolayer = Twolayer> extends Twolayer<Op extends Twolayer<infer N, never> ? N : never, Op extends Twolayer<never, infer L> ? L : never> { /** * set the base {@link Twolayer} for this operator * * Greedy will first call its base operator, and the greedily swap nodes to * minimize edge crossings. To only greedily minimize edge crossings, set * base to a no op. * * (default: noop) */ base<NewOp extends Twolayer>(val: NewOp): TwolayerGreedy<NewOp>; /** * get the current base operator */ base(): Op; /** * set whether this operator should scan to find swaps. * * Using the scan method takes longer (quadratic in layer size, versus * linear), but produces fewer crossings. * * (default: `false`) */ scan(val: boolean): TwolayerGreedy<Op>; /** * get the current scan setting */ scan(): boolean; /** @internal flag indicating that this is built in to d3dag and shouldn't error in specific instances */ readonly d3dagBuiltin: true; } /** default greedy operator */ export type DefaultTwolayerGreedy = TwolayerGreedy<Twolayer<unknown, unknown>>; /** * create a default {@link TwolayerGreedy} * * This may be faster than {@link twolayerOpt}, but should produce better * layouts than {@link twolayerAgg} on its own. * * @example * * ```ts * const layout = sugiyama().decross(decrossTwoLayer().order(twolayerGreedy())); * ``` */ export declare function twolayerGreedy(...args: never[]): DefaultTwolayerGreedy;