<｜begin▁of▁sentence｜>### Instruction:
Given a graph with vertices labeled from 'A' to 'D' and edges connecting them in a linear fashion with weights 1, 2, and 3 respectively, can you write this graph to a file in LEDA format with vertex labels and edge weights?
### Response:
from igraph import Graph

# Create a new graph with 4 vertices and 3 edges
g = Graph(n=4, edges=[(0, 1), (1, 2), (2, 3)])

# Add vertex and edge attributes
g.vs['name'] = ['A', 'B', 'C', 'D']
g.es['weight'] = [1, 2, 3]

# Write to a LEDA format file, storing vertex names and edge weights
g.write_leda('graph.leda', names='name', weights='weight')
<|EOT|>
