DirectedGraph<T extends Object> class Null safety

Generic directed graph storing vertices of type T.

The data-type T should be usable as a map key.

Inheritance
Implementers
Available Extensions

Constructors

DirectedGraph(Map<T, Set<T>> edges, {Comparator<T>? comparator})
Constructs a directed graph. [...]
DirectedGraph.fromWeightedEdges(Map<T, Map<T, dynamic>> weightedEdges, {Comparator<T>? comparator})
Constructs a directed graph from a map of weighted edges.
DirectedGraph.of(DirectedGraph<T> graph)
Constructs a shallow copy of graph.
DirectedGraph.transitiveClosure(DirectedGraph<T> graph)
Factory constructor returning the transitive closure of graph.
factory

Properties

comparator Comparator<T>?
Returns the comparator used to sort graph vertices.
read / write, inherited
crawler GraphCrawler<T>
The graph crawler of this graph.
late, final, inherited
cycle List<T>
Returns the first cycle detected or an empty list if the graph is acyclic. [...]
read-only, inherited
cycleVertex → T?
Returns the first vertex detected that is part of a cycle. [...]
read-only, inherited
data Map<T, Set<T>>
Returns a copy of the graph edges as a map of type Map<T, Set<T>>.
read-only
first → T
Returns the first element. [...]
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
inDegreeMap Map<T, int>
Returns a mapping between vertex and number of incoming connections.
read-only, inherited
isAcyclic bool
Returns true if the graph is a directed acyclic graph.
read-only, inherited
isEmpty bool
Returns true if there are no elements in this collection. [...]
read-only, inherited
isNotEmpty bool
Returns true if there is at least one element in this collection. [...]
read-only, inherited
iterator Iterator<T>
Returns a new Iterator that allows iterating the elements of this Iterable. [...]
read-only, override
last → T
Returns the last element. [...]
read-only, inherited
length int
Returns the number of elements in this. [...]
read-only, inherited
localSources List<List<T>>?
Returns a list of type List<List<T>>. The first entry contains the local source vertices of the graph. Subsequent entries contain the local source vertices of the reduced graph. The reduced graph is obtained by removing all vertices listed in previous entries from the original graph. [...]
read-only, inherited
outDegreeMap Map<T, int>
outgoing connections.
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
single → T
Checks that this iterable has only one element, and returns that element. [...]
read-only, inherited
sortedTopologicalOrdering Set<T>?
Returns an ordered set of all vertices in topological order. [...]
read-only, inherited
sortedVertices Iterable<T>
Returns an Iterable<T> of all vertices sorted using comparator.
read-only, inherited
topologicalOrdering Set<T>?
Returns a set containing all graph vertices in topological order. [...]
read-only, inherited
vertices Iterable<T>
Returns a list of all vertices. [...]
read-only

Methods

addEdges(T vertex, Set<T> connectedVertices) → void
Adds edges (connections) pointing from vertex to connectedVertices.
any(bool test(T element)) bool
Checks whether any element of this iterable satisfies test. [...]
inherited
cast<R>() Iterable<R>
Provides a view of this iterable as an iterable of R instances. [...]
inherited
clear() → void
Removes all graph edges.
contains(Object? element) bool
Whether the collection contains an element equal to element. [...]
inherited
edges(T vertex) Iterable<T>
Returns the vertices connected to vertex. Note: Mathematically, an edge is an ordered pair (vertex, connected-vertex).
elementAt(int index) → T
Returns the indexth element. [...]
inherited
every(bool test(T element)) bool
Checks whether every element of this iterable satisfies test. [...]
inherited
expand<T>(Iterable<T> toElements(T element)) Iterable<T>
Expands each element of this Iterable into zero or more elements. [...]
inherited
firstWhere(bool test(T element), {T orElse()?}) → T
Returns the first element that satisfies the given predicate test. [...]
inherited
fold<T>(T initialValue, T combine(T previousValue, T element)) → T
Reduces a collection to a single value by iteratively combining each element of the collection with an existing value [...]
inherited
followedBy(Iterable<T> other) Iterable<T>
Returns the lazy concatenation of this iterable and other. [...]
inherited
forEach(void action(T element)) → void
Invokes action on each element of this iterable in iteration order.
inherited
inDegree(T vertex) int?
Returns the number of incoming directed edges for vertex. [...]
inherited
join([String separator = ""]) String
Converts each element to a String and concatenates the strings. [...]
inherited
lastWhere(bool test(T element), {T orElse()?}) → T
Returns the last element that satisfies the given predicate test. [...]
inherited
map<T>(T toElement(T e)) Iterable<T>
The current elements of this iterable modified by toElement. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
outDegree(T vertex) int?
Returns the number of outgoing directed edges for vertex. [...]
inherited
path(T start, T target) List<T>
Returns the shortest detected path from start to target including cycles. [...]
inherited
paths(T start, T target) List<List<T>>
Returns all paths from start to target including cycles. [...]
inherited
reachableVertices(T start) Set<T>
Returns an iterable containing all vertices that are reachable from vertex start.
inherited
reduce(T combine(T value, T element)) → T
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function. [...]
inherited
remove(T vertex) → void
Completely removes vertex from the graph, including outgoing and incoming edges.
removeEdges(T vertex, Set<T> connectedVertices) → void
Removes edges (connections) pointing from vertex to connectedVertices. [...]
removeIncomingEdges(T vertex) → void
Removes edges ending at vertex from the graph.
singleWhere(bool test(T element), {T orElse()?}) → T
Returns the single element that satisfies test. [...]
inherited
skip(int count) Iterable<T>
Returns an Iterable that provides all but the first count elements. [...]
inherited
skipWhile(bool test(T value)) Iterable<T>
Returns an Iterable that skips leading elements while test is satisfied. [...]
inherited
sortEdges() → void
Sorts the neighbouring vertices of each vertex using comparator. [...]
take(int count) Iterable<T>
Returns a lazy iterable of the count first elements of this iterable. [...]
inherited
takeWhile(bool test(T value)) Iterable<T>
Returns a lazy iterable of the leading elements satisfying test. [...]
inherited
toList({bool growable = true}) List<T>
Creates a List containing the elements of this Iterable. [...]
inherited
toSet() Set<T>
Creates a Set containing the same elements as this iterable. [...]
inherited
toString() String
Returns a string representation of the graph.
inherited
updateCache() → void
Marks cached variables as stale. This method must be called every time vertices or edges are added or removed from the graph. [...]
inherited
where(bool test(T element)) Iterable<T>
Returns a new lazy Iterable with all elements that satisfy the predicate test. [...]
inherited
whereType<T>() Iterable<T>
Returns a new lazy Iterable with all elements that have type T. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited