<｜begin▁of▁sentence｜>### Instruction:
Given a directed acyclic graph (DAG) with nodes and directed edges, how can we stratify it into topological generations where a node's ancestors are guaranteed to be in a previous generation, and any descendants are guaranteed to be in a following generation? Use the 'topological_generations' function from NetworkX to find the stratification.
### Response:
import networkx as nx

# Create a directed graph
DG = nx.DiGraph([(2, 1), (3, 1)])

# Stratify the graph into topological generations
generations = [sorted(generation) for generation in nx.topological_generations(DG)]

# Print the topological generations
for i, generation in enumerate(generations):
    print('Generation {}: {}'.format(i, generation))
<|EOT|>
