map<T1 extends Object, NewNode extends GraphNode<T1>> method

  1. @override
Graph<T1, NewNode> map<T1 extends Object, NewNode extends GraphNode<T1>>(
  1. NewNode createNode(
    1. T
    )
)
override

Map every node in the graph to an new node type. It may be used for converting from one specialized GraphNode implementation to another, or for converting each GraphNode value from type T to type NewT for example.

Implementation

@override
Graph<T1, NewNode> map<T1 extends Object, NewNode extends GraphNode<T1>>(
  NewNode Function(T) createNode,
) {
  ArgumentError.checkNotNull(createNode);
  final visited = <Node, NewNode>{};
  final newNodes = _nodes
      .map((node) => _createOrGetMappedNode(node, createNode, visited))
      .toList();
  return NodesGraph<T1, NewNode>(newNodes);
}