graphical_models.classes.dags.dag.DAG.add_nodes_from

DAG.add_nodes_from(nodes: Iterable)[source]

Add nodes to the graph from the collection nodes.

Parameters

nodes – collection of nodes to be added.

See also

add_node

Examples

>>> from graphical_models import DAG
>>> g = DAG({1, 2})
>>> g.add_nodes_from({'a', 'b'})
>>> g.add_nodes_from(range(3, 6))
>>> g.nodes
{1, 2, 'a', 'b', 3, 4, 5}