<｜begin▁of▁sentence｜>### Instruction:
Given a directed graph with the edge set [(1, 2), (2, 3), (3, 1), (3, 4), (4, 1), (4, 2)], how can you generate all possible triads using the NetworkX function 'all_triads'?
### Response:
import networkx as nx

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

# Generate all possible triads
for triad in nx.all_triads(G):
    print(triad.edges())
# Output example:
# [(1, 2), (2, 3), (3, 1)]
# [(1, 2), (4, 1), (4, 2)]
# [(3, 1), (3, 4), (4, 1)]
# [(2, 3), (3, 4), (4, 2)]
<|EOT|>
