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.

Type Parameters

Hierarchy

  • Grid
  • layout a graph with the grid layout

    Parameters

    • grf: Ops extends GridOps<N, L>
          ? Graph<N, L>
          : never

      the graph to layout

    Returns LayoutResult

    dimensions - the width and height of the final layout

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

    • val: NewLane

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

    Example

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

    Returns Ops["lane"]

  • Sets this grid layout's node size to the specified two-element array of numbers [ width, height ] and returns a new operator. These sizes are effectively the grid size, e.g. the spacing between adjacent lanes or rows in the grid.

    (default: [1, 1])

    Type Parameters

    Parameters

    • val: NewNodeSize

    Returns Grid<U<Ops, "nodeSize", NewNodeSize>>

  • Get the current node size

    Returns Ops["nodeSize"]

  • set the rank operator for the topological ordering

    Set the rank operator to the given Rank and returns a new version of this operator.

    (default: noop)

    Type Parameters

    • NewRank extends Rank<never, never>

    Parameters

    • val: NewRank

    Returns Grid<U<Ops, "rank", NewRank>>

  • get the current rank operator

    Returns Ops["rank"]

  • set the Tweaks to apply after layout

    Type Parameters

    • const NewTweaks extends readonly Tweak<never, never>[]

    Parameters

    • val: NewTweaks

    Returns Grid<U<Ops, "tweaks", NewTweaks>>

  • get the current Tweaks.

    Returns Ops["tweaks"]

Generated using TypeDoc