<｜begin▁of▁sentence｜>### Instruction:
Given a directed graph with the edge set [(0, 1), (2, 1), (3, 4)], how can you 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
G.add_edges_from([(0, 1), (2, 1), (3, 4)])

# Compute the number of weakly connected components
components = nx.number_weakly_connected_components(G)
print('Number of weakly connected components:', components)
<|EOT|>
