<｜begin▁of▁sentence｜>### Instruction:
Given a directed graph G with nodes [0, 1, 2, 3] and edges [(0, 1), (2, 1)], initially node 3 is not connected to the graph. If an edge (2, 3) is added to G, determine whether the graph is weakly connected both before and after the addition of the edge.
### Response:
import networkx as nx

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

# Add nodes and edges to the graph
G.add_nodes_from([0, 1, 2, 3])
G.add_edges_from([(0, 1), (2, 1)])

# Test for weak connectivity
connected_before = nx.is_weakly_connected(G)

# Add an edge to make the graph weakly connected
G.add_edge(2, 3)

# Test for weak connectivity again
connected_after = nx.is_weakly_connected(G)

# Output the results
print('Is the graph weakly connected before adding (2, 3)?', connected_before)
print('Is the graph weakly connected after adding (2, 3)?', connected_after)
<|EOT|>
