d3-dag
    Preparing search index...

    Interface MutGraphNode<NodeDatum, LinkDatum>

    a mutable node in a graph

    This possesses all of the methods of both MutGraph and GraphNode, while also adding the ability to directly add parents or children and to remove the node and all links from the graph.

    interface MutGraphNode<in out NodeDatum, in out LinkDatum> {
        data: NodeDatum;
        ux?: number;
        uy?: number;
        x: number;
        y: number;
        acyclic(): boolean;
        ancestors(): IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>;
        child(
            chi: MutGraphNode<NodeDatum, LinkDatum>,
            ...datum: undefined extends LinkDatum
                ? [datum?: LinkDatum]
                : [datum: LinkDatum],
        ): MutGraphLink<NodeDatum, LinkDatum>;
        childCounts(): IterableIterator<
            [MutGraphNode<NodeDatum, LinkDatum>, number],
        >;
        childLinks(): IterableIterator<MutGraphLink<NodeDatum, LinkDatum>>;
        childLinksTo(
            node: GraphNode<NodeDatum, LinkDatum>,
        ): IterableIterator<MutGraphLink<NodeDatum, LinkDatum>>;
        children(): IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>;
        connected(): boolean;
        delete(): void;
        descendants(): IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>;
        leaves(): IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>;
        link(
            source: MutGraphNode<NodeDatum, LinkDatum>,
            target: MutGraphNode<NodeDatum, LinkDatum>,
            ...datum: undefined extends LinkDatum
                ? [datum?: LinkDatum]
                : [datum: LinkDatum],
        ): MutGraphLink<NodeDatum, LinkDatum>;
        links(): IterableIterator<MutGraphLink<NodeDatum, LinkDatum>>;
        multi(): boolean;
        nchildLinks(): number;
        nchildLinksTo(node: GraphNode<NodeDatum, LinkDatum>): number;
        nchildren(): number;
        nlinks(): number;
        nnodes(): number;
        node(
            ...datum: undefined extends NodeDatum
                ? [datum?: NodeDatum]
                : [datum: NodeDatum],
        ): MutGraphNode<NodeDatum, LinkDatum>;
        nodes(): IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>;
        nparentLinks(): number;
        nparentLinksTo(node: GraphNode<NodeDatum, LinkDatum>): number;
        nparents(): number;
        parent(
            par: MutGraphNode<NodeDatum, LinkDatum>,
            ...datum: undefined extends LinkDatum
                ? [datum?: LinkDatum]
                : [datum: LinkDatum],
        ): MutGraphLink<NodeDatum, LinkDatum>;
        parentCounts(): IterableIterator<
            [MutGraphNode<NodeDatum, LinkDatum>, number],
        >;
        parentLinks(): IterableIterator<MutGraphLink<NodeDatum, LinkDatum>>;
        parentLinksTo(
            node: GraphNode<NodeDatum, LinkDatum>,
        ): IterableIterator<MutGraphLink<NodeDatum, LinkDatum>>;
        parents(): IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>;
        roots(): IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>;
        split(): IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>;
        toJSON(): unknown;
        topological(
            rank?: Rank<NodeDatum, LinkDatum>,
        ): GraphNode<NodeDatum, LinkDatum>[];
    }

    Type Parameters

    • in out NodeDatum
    • in out LinkDatum

    Hierarchy (View Summary)

    Index

    Properties

    data: NodeDatum

    user data for this node

    ux?: number

    raw (possibly undefined) x coordinate for a node

    uy?: number

    raw (possibly undefined) y coordinate for a node

    x: number

    view of ux that throws if ux is undefined

    y: number

    view of uy that throws if uy is undefined

    Methods

    • remove this node and all of its links from the graph

      Once a node is deleted, none of its methods are valid or guaranteed to do the correct thing.

      Returns void

    • an iterator over the leaves of the graph

      The leaves are defined as a set of nodes such that every node in the graph is an ancestor of one of the leaves, an no leaf is an ancestor of any other leaf. It is guaranteed to include every node with no children, but one node in a cycle may be chosen if there is no unique leaf for that cycle.

      Returns IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>

      the current implementation will return a minimal leaf set as long as target cycles contain a node with a single child.

    • true if at least one node in this graph has multiple links to the same child

      Returns boolean

    • the number of child links

      Returns number

    • the number of unique child nodes

      Returns number

    • an iterator over every node in the graph

      Returns IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>

      Be careful not to modify the graph structure while iterating as any modification, including adding or removing links, can change the behavior of iteration giving unexpected results. If you want to guarantee consistent iteration, allocating an array first with [...graph.nodes()] will ensure consistent iteration.

    • the number of parent links

      Returns number

    • the number of unique parent nodes

      Returns number

    • an iterator over the roots of the graph

      The roots are defined as a set of nodes such that every node in the graph is a descendant of one of the roots, an no root is a descendant of any other root. It is guaranteed to include every node with no parents, but one node in a cycle may be chosen if there is no unique root for that cycle.

      Returns IterableIterator<MutGraphNode<NodeDatum, LinkDatum>>

      the current implementation will return a minimal root set as long as source cycles contain a node with a single parent.

    • serialize the graph

      Returns unknown

      this is intended to be called automatically by JSON.stringify.

    • compute a topological order of the graph

      If the graph can't be represented in topological order, this will try to minimize the number of edge inversions. Optimally minimizing inversions is np-complete, so this will only be approximate.

      You can optionally specify a Rank accessor that defines a numerical rank for every node. Nodes with a lower rank will come before nodes of a higher rank even if that requires more edge inversions. Nodes without a rank are unconstrained.

      Parameters

      Returns GraphNode<NodeDatum, LinkDatum>[]