user data for this node
Optional
uxraw (possibly undefined) x coordinate for a node
Optional
uyraw (possibly undefined) y coordinate for a node
view of ux that throws if ux is undefined
view of uy that throws if uy is undefined
true if there no cycles in the graph
iterator of all nodes reachable though parents
The iterator includes this node.
iterator over this node's unique child nodes and the number of links to them
iterator of links from this node to its children
The order of links is guaranteed to not change between iterations.
iterator over this node's unique child nodes
true if every node in the graph is reachable from every other
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.
iterator of all nodes reachable though children
The iterator includes this node.
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.
add a new link from source to target
If undefined
extends LinkDatum, datum can be elided and simply called as
grf.link(source, target);
an iterator over every link in the graph
true if at least one node in this graph has multiple links to the same child
the number of child links
the number of unique child nodes
the number of links in the graph
the number of nodes in the graph
an iterator over every node in the graph
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
the number of unique parent nodes
iterator over this node's unique parent nodes and the number of links from them
iterator of links to this node from its parents
The order of links is guaranteed to not change between iterations.
iterator over this node's unique parent nodes
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.
split a graph into connected components
splits an iterable over a single node in each connected component
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.
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.