<｜begin▁of▁sentence｜>### Instruction:
Given a directed graph with 3 nodes and 2 directed edges from node 0 to node 1 and from node 1 to node 2, can you use DarkToLightEdgeDrawer.draw_directed_edge function in igraph to draw each directed edge with a gradient from black to red?
### Response:
import igraph as ig
import cairo

# Assuming you have a directed graph `g` with vertices and edges already added
g = ig.Graph(directed=True)
g.add_vertices(3)
g.add_edges([(0, 1), (1, 2)])

# Create a Cairo surface to draw on
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 400, 400)
ctx = cairo.Context(surface)

# Define a color palette
palette = ig.GradientPalette('black', 'red')

# Create an instance of the DarkToLightEdgeDrawer
edge_drawer = ig.drawing.cairo.edge.DarkToLightEdgeDrawer(ctx, palette)

# Use the custom edge drawer to draw a directed edge
edge_drawer.draw_directed_edge(g.es[0], [0, 0], [100, 100])

# Save the surface to PNG
surface.write_to_png('directed_edge.png')
<|EOT|>
