Interface GraphNode<NodeDatum, LinkDatum>

a node in a graph

Nodes provide all the same interfaces that Graphs do in terms of node properties and iteration. When called on a node, the nodes behaves as a graph of just its connected component. Therefore new nodes will always be acyclic, connected, and not multi.

In addition, nodes also expose properties of their immediate neighborhoods, iterators and counts of nodes they directly touch.

This is the immutable version of MutGraphNode.

Type Parameters

  • out NodeDatum = unknown

  • out LinkDatum = unknown

Hierarchy

  • Graph<NodeDatum, LinkDatum>
  • GraphNodeMixin<NodeDatum, LinkDatum>
    • GraphNode

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

  • iterator of all nodes reachable though parents

    The iterator includes this node.

    Returns IterableIterator<GraphNode<NodeDatum, LinkDatum>>

  • iterator over this node's unique child nodes and the number of links to them

    Returns IterableIterator<[GraphNode<NodeDatum, LinkDatum>, number]>

  • iterator of links from this node to its children

    The order of links is guaranteed to not change between iterations.

    Returns IterableIterator<GraphLink<NodeDatum, LinkDatum>>

  • iterator over every link to a specific node

    Parameters

    Returns IterableIterator<GraphLink<NodeDatum, LinkDatum>>

  • iterator over this node's unique child nodes

    Returns IterableIterator<GraphNode<NodeDatum, LinkDatum>>

  • true if every node in the graph is reachable from every other

    Returns boolean

  • iterator of all nodes reachable though children

    The iterator includes this node.

    Returns IterableIterator<GraphNode<NodeDatum, LinkDatum>>

  • 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<GraphNode<NodeDatum, LinkDatum>>

    Remarks

    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 links to a specific node

    Parameters

    Returns number

  • the number of unique child nodes

    Returns number

  • an iterator over every node in the graph

    Returns IterableIterator<GraphNode<NodeDatum, LinkDatum>>

    Remarks

    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 links from a specific node

    Parameters

    Returns number

  • the number of unique parent nodes

    Returns number

  • iterator over this node's unique parent nodes and the number of links from them

    Returns IterableIterator<[GraphNode<NodeDatum, LinkDatum>, number]>

  • iterator of links to this node from its parents

    The order of links is guaranteed to not change between iterations.

    Returns IterableIterator<GraphLink<NodeDatum, LinkDatum>>

  • iterator over every link from a specific node

    Parameters

    Returns IterableIterator<GraphLink<NodeDatum, LinkDatum>>

  • iterator over this node's unique parent nodes

    Returns IterableIterator<GraphNode<NodeDatum, LinkDatum>>

  • 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<GraphNode<NodeDatum, LinkDatum>>

    Remarks

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

  • split a graph into connected components

    Returns IterableIterator<GraphNode<NodeDatum, LinkDatum>>

    splits an iterable over a single node in each connected component

    Remarks

    Since each node behaves like a graph of its connected component, this is equivalent with returning a graph of each connected component.

  • serialize the graph

    Returns unknown

    Remarks

    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

    • Optional rank: Rank<NodeDatum, LinkDatum>

    Returns GraphNode<NodeDatum, LinkDatum>[]

Generated using TypeDoc