<｜begin▁of▁sentence｜>### Instruction:
Given a graph whose edge set is [(1, 2), (2, 3), (3, 4), (4, 1), (1, 3)], how can you use NetworkX to create and display a subgraph that includes only the nodes 1, 2, and 3 along with the edges connecting them?
### Response:
import networkx as nx

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

# Generate a subgraph containing only a specified subset of nodes
subgraph_nodes = [1, 2, 3]
H = G.subgraph(subgraph_nodes)

# Print the edges of the subgraph
print(list(H.edges()))
<|EOT|>
