<｜begin▁of▁sentence｜>### Instruction:
Given a directed graph with 5 vertices and 4 edges connecting them sequentially, and edge capacities [10, 20, 30, 40], how would you write this graph in DIMACS format with source vertex 0, target vertex 4, using igraph's write_dimacs function?
### Response:
import igraph as ig

# Create a directed graph
g = ig.Graph(directed=True)
# Add 5 vertices
for _ in range(5):
    g.add_vertex()
# Add edges with corresponding capacities
g.add_edges([(0, 1), (1, 2), (2, 3), (3, 4)])
g.es['capacity'] = [10, 20, 30, 40]

# Write the graph to a DIMACS file
output_file = 'output.dimacs'
g.write_dimacs(f=output_file, source=0, target=4, capacity=g.es['capacity'])
<|EOT|>
