<｜begin▁of▁sentence｜>### Instruction:
Imagine you're in charge of organizing the social interactions within a group of animals, and you've observed their interactions to create a social map. The interactions can be summarized by a degree sequence: each animal has a certain number of preferred partners. The sequence [3, 2, 2, 1, 0] represents five animals, where the first animal prefers to interact with three others, the second and third with two others, the fourth with one, and the fifth is solitary.

Employ the Havel-Hakimi algorithm, much like a meticulous procedure to structure the social dynamic, ensuring that the preferred number of partners for each animal is accounted for. With the social structure laid out, utilize the 'NetworkX' system to dissect the modularity matrix of this network. It's akin to mapping out the relationships to understand the interconnectedness and cliques within this small society.

Be sure to maintain a record of the findings, much as you would for veterinary records, to enhance the welfare of the group and to inform future care and interaction plans. This approach captures the essence of your role, blending technical logistics with the welfare of the animals in your care.
### Response:
import networkx as nx
import numpy as np

# Create a graph using Havel-Hakimi algorithm from a degree sequence
k = [3, 2, 2, 1, 0]
G = nx.havel_hakimi_graph(k)

# Calculate the modularity matrix
B = nx.modularity_matrix(G)

# Print the modularity matrix
print('Modularity matrix:\n', B)
<|EOT|>
