d3-dag
Version:
Layout algorithms for visualizing directed acylic graphs.
34 lines (33 loc) • 1.57 kB
TypeScript
import { GraphNode } from "../graph";
import { NodeLength } from "../layout";
/**
* A separation function that indicates how far apart nodes should be the layering / height assignment.
*
*
* @remarks upper and lower are historic, since arbitrary graphs are handled,
* there is no longer a notion of upper or lower and separation should return
* the correct separation independent of nodes relations in the graph.
*/
export interface Separation<in NodeDatum = never, in LinkDatum = never> {
/**
* compute the necessary separation between two nodes
*
* `first` and `second` are `undefined` to indicate the separation from the
* extents of the layout (0, or height). Both will never be `undefined`.
*
* @param first - one node to find the separation between
* @param second - the other node to find the separation between
* @returns sep - the minimum separation between the two nodes, regardless of which
* one is on top
*/
(first: GraphNode<NodeDatum, LinkDatum> | undefined, second: GraphNode<NodeDatum, LinkDatum> | undefined): number;
}
/**
* A separation derived from a length and a gap
*
* This is the separation function if each node has size `len` and between two
* nodes there's an extra `gap`.
*/
export declare function sizedSeparation<NodeDatum, LinkDatum>(len: NodeLength<NodeDatum, LinkDatum>, gap: number): Separation<NodeDatum, LinkDatum>;
/** compute the number of crossings in a layered sugi node */
export declare function crossings(layers: readonly (readonly GraphNode[])[]): number;