<｜begin▁of▁sentence｜>### Instruction:
Given an integer n representing the number of nodes, the code sample generates a random labeled rooted forest using a generalization of Prüfer sequences. It prints the edges of the forest and identifies its roots. For example, how would you generate and display the edges and roots of such a forest with 5 nodes?
### Response:
import networkx as nx

# Generate a random labeled rooted forest with 5 nodes
forest = nx.random_labeled_rooted_forest(n=5, seed=42)

# Print the edges of the forest
print(list(forest.edges()))

# Print the roots of the forest
print(forest.graph['roots'])
<|EOT|>
