<｜begin▁of▁sentence｜>### Instruction:
Given an undirected graph where nodes represent people and weighted edges represent the frequency of interactions between them, and given a community partitioning scheme where each person is assigned to a community, can you calculate the modularity component for each community to assess the strength of the community division?
### Response:
import networkx as nx
from graspologic.partition import modularity_components

# Example graph with community structure
G = nx.Graph()
G.add_nodes_from([1, 2, 3, 4, 5, 6, 7, 8])
G.add_weighted_edges_from([(1, 2, 3.0), (2, 3, 2.5), (3, 4, 1.0), (4, 5, 2.0), (5, 6, 3.5), (6, 7, 1.0), (7, 8, 2.5), (8, 1, 1.0), (1, 5, 2.0)])

# Community partitioning
partitions = {1: 0, 2: 0, 3: 0, 4: 1, 5: 1, 6: 1, 7: 0, 8: 0}

# Calculating modularity components
modularity_quanta = modularity_components(G, partitions, weight_attribute='weight', resolution=1.0)

# Printing the modularity of each community
for community_id, modularity in modularity_quanta.items():
    print(f'Community {community_id}: Modularity = {modularity}')
<|EOT|>
