<｜begin▁of▁sentence｜>### Instruction:
Given a weighted undirected graph with an edge set [(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 1, 1), (1, 3, 3)], can you create a spanner for this graph with a stretch factor of 2 using the NetworkX library?
### Response:
import networkx as nx

# Create a graph
G = nx.Graph()
G.add_weighted_edges_from([(1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 1, 1), (1, 3, 3)])

# Generate a spanner with stretch factor of 2
spanner_graph = nx.algorithms.spanner(G, stretch=2, weight='weight', seed=42)

print(spanner_graph.edges(data=True))
<|EOT|>
