DirectedGraph<T extends Object> constructor
DirectedGraph<T extends Object> (
- Map<
T, Set< edges, {T> > - Comparator<
T> ? comparator,
Constructs a directed graph.
edges
: a map of typeMap<T, Set<T>>
,comparator
: a function with typedefComparator<T>
used to sort the graph vertices.
Implementation
DirectedGraph(
Map<T, Set<T>> edges, {
Comparator<T>? comparator,
}) : super(comparator) {
edges.forEach((vertex, connectedVertices) {
_edges[vertex] = Set<T>.of(connectedVertices);
for (final connectedVertex in connectedVertices) {
_edges[connectedVertex] ??= <T>{};
}
});
}