graph library

Classes

Graph<T, Node extends GraphNode<T>>
GraphEdge<Node extends GraphNode<Object>>
An edge from 2 GraphNodes in a graph.
GraphNode<T>
An node in a graph in which the edges may be interlinked or not. This interface is used for algorithms which may work only for GraphNodes.
Node<T>
An node in a graph. The edges may be interlinked or not. This interface is used for generalized algorithms which may work for TreeNodes or GraphNodes.
NodesGraph<T, Node extends GraphNode<T>>
RootGraph<T, Node extends GraphNode<T>>
TreeNode<T>
An node in a tree. The edges are NOT interlinked, and two nodes must be connected by exactly ONE edge.

Enums

TreeToGraphLinkType
An enum of ways to convert an parent-child relation on a tree to edges on a graph.

Functions

graphEdges<Node extends GraphNode<Object>>(Node root, {Set<Node>? visited}) Iterable<GraphEdge<Node>>
Get an iterable of every GraphEdge in a graph. Every edge will be emitted exactly once. If an edge is interlinked, it will be emitted once for the first node linking to the second and once for the second node linking to the first.
mapTree<T, T1 extends TreeNode<Object>>(TreeNode<T> root, T1 createNode(T value, Iterable<T1> children)) → T1
Map every node in a tree to an new node type. It may be used for converting from one specialized TreeNode implementation to another, or for converting each TreeNode value from type T to type NewT for example.
nothing<T>([Object? o]) → T?
treeToGraph<T, Node extends GraphNode<T>>(TreeNode<T> root, Node createNode(T value), {TreeToGraphLinkType linkType = TreeToGraphLinkType.direct}) Graph<T, Node>
Convert an tree, which may have more than one TreeNode representing the same value into an Graph, which may be interlinked or not.
treeToString<Node extends TreeNode<Object>>(Node root, [String describeNode(Node)?]) String
Converts an tree to an textual representation in a manner similar to the tree command.
walkTree<T, T1>(TreeNode<T> root, T1 fn(T node, Maybe<T> parent), {Maybe<T> parent = const None()}) Iterable<T1>
Visit every node in a tree, call the fn for each and collect the results in an Iterable.