<｜begin▁of▁sentence｜>### Instruction:
Given a directed graph with nodes and directed edges, how can I determine the number of weakly connected components in the graph using NetworkX?
### Response:
import networkx as nx

# Create a directed graph
G = nx.DiGraph()

# Add edges to the graph (nodes are added automatically)
G.add_edges_from([(0, 1), (2, 1), (3, 4), (4, 5)])

# Use the function to find the number of weakly connected components
num_components = nx.number_weakly_connected_components(G)

print('Number of weakly connected components:', num_components)
<|EOT|>
