Interface Hierarchy<NodeDatum, LinkDatum, Child, ChildData>

create a MutGraph from hierarchical data

By default, each piece of data passed in corresponds to a node, and their children will be explored recursively creating more nodes. Use children to change how children are found, or childrenData to also attach link data.

Created with graphHierarchy.

Type Parameters

  • NodeDatum

  • LinkDatum

  • Child extends Children<NodeDatum>

  • ChildData extends ChildrenData<NodeDatum, LinkDatum>

Hierarchy

  • Hierarchy
  • construct a graph from hierarchical data

    Parameters

    • Rest ...data: readonly NodeDatum[]

      a source node to recursively find children of; you can pass multiple source nodes for disconnected or multi-rooted graphs

    Returns MutGraph<NodeDatum, LinkDatum>

    graph - a graph of the hierarchical data

Methods

  • set a new children accessor

    This accessor takes passed in node data and returns an iterable of new node data that correspond to that nodes children. When this is specified, link data are left undefined.

    Due to the way typescript inference happens, to make this accessor valid you will likely have to define a separate interface for the data type so that the recursive definition of children can be specified.

    The default accessor is:

    ({ children }) => children
    

    Type Parameters

    • NewNode

    • NewChildren extends Children<NewNode>

    Parameters

    Returns Hierarchy<NewNode, undefined, NewChildren, WrappedChildren<NewNode, NewChildren>>

  • get the current children accessor

    This is the current Children. If childrenData was specified, this will return a wrapped version that returns only the children of that operator.

    Returns Child

  • set a new children data accessor

    This accessor takes passed in node data and returns an iterable with tuples of new node data and the link data for the corresponding link. Use this function when your graph data has link information that you want to preserve in the graph structure for easy access from links.

    Type Parameters

    • NewNode

    • NewLink

    • NewChildrenData extends ChildrenData<NewNode, NewLink>

    Parameters

    Returns Hierarchy<NewNode, NewLink, WrappedChildrenData<NewNode, NewChildrenData>, NewChildrenData>

    Example

    (nodeData) => [[childData, linkData]]
    
  • get the current children data accessor

    This is the current ChildrenData. If children was specified, this will return a wrapped version that returns undefined for all link data.

    Returns ChildData

Generated using TypeDoc