<｜begin▁of▁sentence｜>### Instruction:
Given a directed graph with edges (1,2), (2,3), (3,4), and (4,2), how can you draw the graph with arrows using matplotlib?
### Response:
import networkx as nx
import matplotlib.pyplot as plt

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

dg.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 2)])

# Draw the graph with arrows, which sizes are not specified and therefore default
pos = nx.spring_layout(dg)
nx.draw(dg, pos, with_labels=True, arrows=True)

# Display the directed graph
plt.show()
<|EOT|>
