<｜begin▁of▁sentence｜>### Instruction:
Given an Erdos-Renyi network graph with 100 nodes and a connection probability of 0.1, how can you retrieve the initial and final level of hierarchical clustering after performing the hierarchical leiden algorithm to detect communities within the graph?
### Response:
import networkx as nx
from graspologic.partition import hierarchical_leiden
from graspologic.simulations import er_np

# Generate a sample Erdos-Renyi graph
np.random.seed(42)
G = er_np(n=100, p=0.1)

# Perform hierarchical leiden algorithm to detect communities
partitions = hierarchical_leiden(G)

# HierarchicalClusters stores the history of partitions at every level
# Retrieve the first and final level of hierarchical clustering
initial_clustering = partitions.first_level_hierarchical_clustering()
final_clustering = partitions.final_level_hierarchical_clustering()

# Print the initial and final level of hierarchical clustering
print('Initial clustering:', initial_clustering)
print('Final clustering:', final_clustering)
<|EOT|>
