Walkable<E>.circular constructor

Walkable<E>.circular(
  1. Set<E> nodes
)

Creates a walkable with a circular topology.

Each node in the circular walkable is connected to the next node in the sequence, and the last node is connected to the first node.

At least one node must be provided.

Example

final walkable = Walkable.circular(['a', 'b', 'c']);

print(walkable.successors('a')); // ['b']
print(walkable.successors('b')); // ['c']
print(walkable.successors('c')); // ['a']

Implementation

factory Walkable.circular(Set<E> nodes) {
  final list = List.of(nodes);
  if (list.isEmpty) {
    throw ArgumentError.value(nodes, 'nodes', 'Must not be empty');
  }
  list.add(list.first);
  return _LinearWalkable._(list);
}