A collection of nodes and edges where edges connect exactly two nodes.
Associated data for each node, E
, is stored in the graph, and edges are
represented as a pair of nodes, and have no associated data unless the graph
is a WeightedGraph.
A graph can be either directed, i.e. an edge has a source and a target node, or undirected, where there is no such distinction, but most algorithms and operations are applicable to both types of graphs.
- Implemented types
- Implementers
Constructors
- Graph({bool directed = true})
-
Creates an empty AdjacencyListGraph.
factory
-
Graph.from(WalkableBase<
E> walkable, {bool directed}) -
Creates a AdjacencyListGraph graph from a
walkable
.factory -
Graph.fromEdges(Iterable<
Edge< edges, {bool directed})E> > -
Creates a AdjacencyListGraph graph from
edges
.factory
Properties
-
edges
→ Iterable<
Edge< E> > -
Each edge in the collection.
no setterinherited
- 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
-
addEdge(
Edge< E> edge) → bool -
Adds an
edge
from to the graph. -
addEdges(
Iterable< Edge< edges) → voidE> > - Adds multiple edges to the graph.
-
asUnweighted(
) → Walkable< E> -
Returns a view of this walkable as an unweighted walkable.
inherited
-
asWeighted(
double weight(E source, E target)) → WeightedWalkable< E> -
Returns a view of this walkable as a weighted walkable.
inherited
-
clear(
) → void - Clears the graph of all nodes and edges.
-
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) → bool -
Removes an
edge
from the graph.override -
successors(
E node) → Iterable< E> -
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