Interface LayeringSimplex<Ops>

A layering operator that assigns layers to minimize the number of dummy nodes (long edges) added to the layout.

Computing this layering requires solving an integer linear program, which may take a long time, although in practice is often quite fast. This is often known as the network simplex layering from Gansner et al. [1993].

Because this is solving a linear program, it is relatively easy to add new constraints. The current implementation allows specifying rank constraints that indicate which nodes should be above other nodes, or group constraints that say which nodes should be on the same layer. Note that adding these constraints can cause the optimization to become ill-defined.

Create with layeringSimplex.

interface LayeringSimplex<Ops extends LayeringSimplexOps = LayeringSimplexOps> {
    group<NewGroup extends Group<never, never>>(
        newGroup: NewGroup,
    ): LayeringSimplex<U<Ops, "group", NewGroup>>;
    group(): Ops["group"];
    rank<NewRank extends Rank<never, never>>(
        newRank: NewRank,
    ): LayeringSimplex<U<Ops, "rank", NewRank>>;
    rank(): Ops["rank"];
    <N extends unknown, L extends unknown>(
        graph: Graph<N, L>,
        sep: Separation<N, L>,
    ): number;
}

Type Parameters

Hierarchy (View Summary)

  • layer a graph

    After calling this, every node should have a y coordinate that satisfies sep.

    Type Parameters

    • N extends unknown
    • L extends unknown

    Parameters

    • graph: Graph<N, L>

      the graph to layer

    • sep: Separation<N, L>

      the minimum separation between nodes

    Returns number

    height - the height after layering

Methods

Methods