GraphBase<E> class abstract interface Graphs

A base interface for graphs.

Most algorithms in this library are implemented in terms of graphs, which are collections of nodes and edges, but there are two types of graphs:

  • Graph, which represents edges without weights.
  • WeightedGraph, which represents edges with weights.

This interface provides a common base class for both types of graphs, allowing algorithms to be implemented in terms of GraphBase rather than Graph or WeightedGraph specifically if they support both types.

Example

// An algorithm that accepts only unweighted graphs.
void acceptsOnlyUnweighted(Graph<String> graph) {}

// An algorithm that accepts only weighted graphs.
void acceptsOnlyWeighted(WeightedGraph<String, int> graph) {}

// An algorithm that accepts both unweighted and weighted graphs.
void acceptsBoth(GraphBase<String> graph) {
  acceptsOnlyUnweighted(graph.asUnweighted());
}
Implemented types
Implementers

Properties

hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Returns true if the walkable collection has no nodes.
no setterinherited
isNotEmpty bool
Returns true if the walkable collection has one or more nodes.
no setterinherited
roots Iterable<E>
Each node that is exposed as a root node of the walkable collection.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

asUnweighted() Walkable<E>
Returns a view of this walkable as an unweighted walkable.
inherited
containsEdge(Edge<E> edge) bool
Returns whether the collection contains an edge connecting two nodes.
inherited
containsRoot(E node) bool
Returns whether the collection contains a root node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeEdge(Edge<E> edge) → void
Removes an edge from the graph.
successors(E node) Iterable<void>
Returns each distinct node that is a direct successor of the given node.
inherited
toString() String
A string representation of this object.
inherited

Operators

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