<｜begin▁of▁sentence｜>### Instruction:
As an editor, imagine you are overseeing a manuscript detailing an analysis of sociological interactions within a small networked community. The narrative charts the interconnectedness of ten distinct individuals (notated as nodes) within the community, each engaged in various interactions of disparate significance (depicted as weighted, undirected edges). These individuals are further grouped into three distinct subcommunities.

Your task is to refine the exposition surrounding a specific analytical method—the 'modularity_components' function from the 'graspologic.partition' module—employed by the author to delineate the individual contributions of each subcommunity to the overall cohesion or modularity of the social network. How might you reformulate the original passage to clearly articulate the process by which the 'modularity_components' function is leveraged to quantify the modularity attributable to each of the three subcommunities? 

Ensure that your revision elucidates this complex concept in a manner that harmoniously integrates with the broader theme of the manuscript. The goal is to present this information so that both scholarly and general readers can appreciate the significance of these modularity calculations within the context of the community study.
### Response:
import networkx as nx
from graspologic.partition import modularity_components
import numpy as np

# Create a weighted undirected graph
G = nx.Graph()
nodes = range(10)
edges = [(i, j, {'weight': np.random.rand()}) for i in nodes for j in nodes if i < j]
G.add_nodes_from(nodes)
G.add_edges_from(edges)

# Define a community partitioning
partitions = {0: 0, 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 2, 7: 2, 8: 2, 9: 2}

# Calculate the modularity components for each community
modularity_comps = modularity_components(graph=G, partitions=partitions, weight_attribute='weight', resolution=1.0)

# Output the modularity components
display(modularity_comps)
<|EOT|>
