<｜begin▁of▁sentence｜>### Instruction:
Given a directed graph with edges [(0, 1), (1, 2), (2, 3), (3, 0)] and capacities [10, 20, 30, 40] for each edge, how can you write this graph to a file in DIMACS format specifying a source vertex 0 and a target vertex 2?
### Response:
from igraph import Graph

# Define a directed graph with edge capacities
g = Graph([(0, 1), (1, 2), (2, 3), (3, 0)], directed=True)
g.es['capacity'] = [10, 20, 30, 40]  # Assigning capacities to edges

# Set the source and target
source = 0
target = 2

# Write the graph to a DIMACS formatted file
file_name = 'output.dimacs'
g.write_dimacs(f=file_name, source=source, target=target, capacity='capacity')
print(f'Graph written to {file_name} in DIMACS format')
<|EOT|>
