<｜begin▁of▁sentence｜>### Instruction:
Consider a graph with the following edges: [(1,2), (1,3), (2,4), (2,5)]. After adding these edges to the graph, check whether the graph is a forest. Then, add an edge (4,1) that creates a cycle and check if the graph is still a forest.
### Response:
import networkx as nx

# Create a graph
G = nx.Graph()

# Add edges to the graph (nodes are added automatically)
G.add_edges_from([(1,2),(1,3),(2,4),(2,5)])

# Check if the graph is a forest
is_forest = nx.is_forest(G)
print('Is the graph a forest?', is_forest)

# Add an edge that creates a cycle
G.add_edge(4,1)

# Re-check if the graph is now a forest
is_forest = nx.is_forest(G)
print('Is the graph a forest after adding an edge (4,1)?', is_forest)
<|EOT|>
