Interface Grid<Ops>

A simple grid based topological layout operator.

This layout algorithm constructs a topological representation of the dag meant for visualization. The nodes are topologically ordered and then nodes are put into lanes such that an edge can travel horizontally to the lane of a child node, and then down without intersecting to that child.

Create with grid.

interface Grid<Ops extends GridOps = GridOps> {
    gap(val: readonly [number, number]): Grid<Ops>;
    gap(): readonly [number, number];
    lane<NewLane extends Lane<never, never>>(
        val: NewLane,
    ): Grid<U<Ops, "lane", NewLane>>;
    lane(): Ops["lane"];
    nodeSize<NewNodeSize extends NodeSize>(
        val: NewNodeSize,
    ): Grid<U<Ops, "nodeSize", NewNodeSize>>;
    nodeSize(): Ops["nodeSize"];
    rank<NewRank extends Rank<never, never>>(
        val: NewRank,
    ): Grid<U<Ops, "rank", NewRank>>;
    rank(): Ops["rank"];
    tweaks<const NewTweaks extends readonly Tweak<never, never>[]>(
        val: NewTweaks,
    ): Grid<U<Ops, "tweaks", NewTweaks>>;
    tweaks(): Ops["tweaks"];
    (grf: Ops extends GridOps<N, L> ? Graph<N, L> : never): LayoutResult;
}

Type Parameters

Methods

  • Set the gap size between nodes

    (default: [1, 1])

    Parameters

    • val: readonly [number, number]

    Returns Grid<Ops>

  • Get the current gap size

    Returns readonly [number, number]

  • set a custom Lane operator

    The lane operator controls how nodes are assigned to horizontal lanes. This is the core piece of the layout. There are two builtin lane operators:

    • laneGreedy - This is a fast reasonably effective lane operator. It supports a number of further tweaks to alter the layout.
    • laneOpt - This assigns lanes to optimally minimize the number of edge crossings. This optimization is NP Hard, so outside of very small graphs, it will likely take too long to execute.

    You can also supply any function that satisfies the Lane interface. See that documentation for more information about implementing your own lane assignment.

    (default: laneGreedy)

    Type Parameters

    • NewLane extends Lane<never, never>

    Parameters

    Returns Grid<U<Ops, "lane", NewLane>>

    const layout = grid().lane(laneOpt());
    
  • get the current lane operator

    Returns Ops["lane"]