<｜begin▁of▁sentence｜>### Instruction:
Given an undirected graph with edges [(1, 2), (1, 3), (3, 4)], can you calculate the density of the graph using networkx?
### Response:
import networkx as nx

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

# Calculate the density of the graph
density = nx.density(G)
print('Density of the graph:', density)
<|EOT|>
