AdjacencyListGraph<E>.from constructor

AdjacencyListGraph<E>.from(
  1. WalkableBase<E> walkable, {
  2. bool directed = true,
})

Creates an adjacency list graph from a walkable.

Each edge in the walkable is added to the graph, similar to calling:

final graph = AdjacencyListGraph<E>();
graph.addEdges(walkable.edges);

If directed is true, which is the default, the graph is directed, i.e. an edge has an explicit source and a target node. If directed is false, the graph is undirected, and the inverse of an edge is also an edge.

Implementation

factory AdjacencyListGraph.from(
  WalkableBase<E> walkable, {
  bool directed = true,
}) {
  return AdjacencyListGraph.fromEdges(
    walkable.asUnweighted().edges,
    directed: directed,
  );
}