Graph<T> class

A Graph of Nodes.

  • Can be generated by GraphScanner.searchPaths.
Implemented types

Constructors

Graph()
Graph.fromJson(Map<String, dynamic> json, {T nodeValueMapper(GraphStep<T>? previousStep, String key)?})
Creates a Graph from json.
factory

Properties

allLeaves List<Node<T>>
Returns all the leaves of this graph (nodes without outputs)
no setter
allNodes Iterable<Node<T>>
Returns all the Nodes in this graph.
no setter
allNodesValues Iterable<T>
Returns all the Node.values in this graph.
no setter
allPaths Future<List<List<Node<T>>>>
Returns all the paths from roots to allLeaves;
no setter
hashCode int
The hash code for this object.
no setterinherited
inputs List<Node<T>>
Alias to allNodes.
no setteroverride
isEmpty bool
Returns true this graph is empty.
no setter
isNotEmpty bool
Returns true this graph NOT is empty.
no setter
length int
Returns the total amount of Nodes in this graph.
no setter
outputs List<Node<T>>
Alias to allNodes.
no setteroverride
roots List<Node<T>>
Returns a list of root nodes (without inputs).
no setter
rootValues List<T>
Returns a list of root values (without inputs).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shortestPaths Future<List<List<Node<T>>>>
Returns all the shortest paths from root to allLeaves.
no setter
targets List<Node<T>>
Returns a list of nodes market as targets.
no setter

Methods

addInput(T nodeValue) Node<T>?
Adds a Node to the graph. Alias to node.
override
addOutput(T nodeValue) Node<T>?
Adds a Node to the graph. Alias to node.
override
containsInput(T nodeValue) bool
Returns true if contains a Node with nodeValue. See allNodes
override
containsOutput(T nodeValue) bool
Returns true if contains a Node with nodeValue. See allNodes
override
dispose() → void
Disposes this graphs, cleaning internal references to this Graph from Nodes.
getNode(T? value) Node<T>?
Returns a Node with value or null if not present.
getNodes(Iterable<T> values) Iterable<Node<T>>
Returns a list of Node with values present.
getNodesNullable(Iterable<T> values) Iterable<Node<T>?>
Returns a list of Node with values or null for absent nodes.
node(T value) Node<T>
Returns a Node with value or creates it.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
populate<R>(Iterable<T> entries, {GraphWalkNodeProvider<T>? nodeProvider, GraphWalkOutputsProvider<T>? inputsProvider, GraphWalkOutputsProvider<T>? outputsProvider, GraphWalkNodeProcessor<T, R>? process, int maxExpansion = 3, bool bfs = false}) → R?
Populates this graph with entries.
populateAsync<R>(Iterable<T> entries, {GraphWalkNodeProviderAsync<T>? nodeProvider, GraphWalkOutputsProviderAsync<T>? inputsProvider, GraphWalkOutputsProviderAsync<T>? outputsProvider, GraphWalkNodeProcessorAsync<T, R>? process, int maxExpansion = 3, bool bfs = false}) Future<R?>
reset() → void
Resets this graph and all its Nodes for a path scan. See Node.reset.
override
root(T value) Node<T>
Returns a Node with value or creates it as always root.
scanPathsFrom(T root, T target, {bool findAll = false}) Future<GraphScanResult<T>>
Scans and returns the paths from root to target.
scanPathsFromMany(List<T> roots, List<T> targets, {bool? findAll}) Future<GraphScanResult<T>>
Scans and returns the paths from roots to targets.
scanPathsMatching(List<T> roots, NodeMatcher<T> targetMatcher, {bool findAll = true}) Future<GraphScanResult<T>>
Scans and returns the paths from root to Nodes matching targetMatcher.
shortestPathsFrom(T root, T target, {bool findAll = false}) Future<List<List<Node<T>>>>
Returns the shortest paths from root to target.
shortestPathsFromMany(List<T> roots, List<T> targets, {bool findAll = false}) Future<List<List<Node<T>>>>
Returns the shortest paths from roots to targets.
shortestPathsMatching(List<T> roots, NodeMatcher<T> targetMatcher, {bool findAll = true}) Future<List<List<Node<T>>>>
Returns the shortest paths from roots to Nodes matching targetMatcher.
toJson({bool sortByInputDependency = false}) Map<String, dynamic>
Returns a JSON representation of this graph.
toString() String
A string representation of this object.
inherited
toTree<K>({K keyCast(T value)?, bool sortByInputDependency = false, bool bfs = false}) Map<K, dynamic>
Returns a Map representation of this graph.
toTreeFrom<K>(List<T> roots, {K keyCast(T value)?, bool sortByInputDependency = false, bool bfs = false}) Map<K, dynamic>
Returns a Map representation of this graph from roots.
valuesToNodes(Iterable<T> values, {bool createNodes = false}) Iterable<Node<T>>
Maps values to Nodes in this graph.
walkInputsFrom<R>(Iterable<T> from, GraphWalkNodeProcessor<T, R> process, {NodeMatcher<T>? stopMatcher, bool processRoots = true, int maxExpansion = 1, bool bfs = false}) → R?
Walk the graph nodes inputs starting from and stopping at stopMatcher (if provided).
walkInputsOrderFrom<R>(Iterable<T> from, {NodeMatcher<T>? stopMatcher, bool processRoots = true, int maxExpansion = 1, bool sortByInputDependency = false, bool bfs = false}) List<Node<T>>
Walk the graph nodes outputs starting from and stopping at stopMatcher (if provided).
walkOutputsFrom<R>(Iterable<T> from, GraphWalkNodeProcessor<T, R> process, {NodeMatcher<T>? stopMatcher, bool processRoots = true, int maxExpansion = 1, bool bfs = false}) → R?
Walk the graph nodes outputs starting from and stopping at stopMatcher (if provided).
walkOutputsOrderFrom<R>(Iterable<T> from, {NodeMatcher<T>? stopMatcher, bool processRoots = true, int maxExpansion = 1, bool expandSideRoots = false, bool sortByInputDependency = false, bool bfs = false}) List<Node<T>>
Walk the graph nodes outputs starting from and stopping at stopMatcher (if provided).

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](T value) Node<T>?
Alias to getNode.