<｜begin▁of▁sentence｜>### Instruction:
Imagine you want to create a synthetic network to model communities within a larger population. You're planning to design a graph that contains three distinct groups of individuals, with different levels of interaction within and between these groups. The first group consists of 10 individuals, the second of 20, and the third of 30. People within the same group know each other with a 50% chance, while individuals from different groups only have a 5% chance of being acquainted. How can you generate this graph, view the groupings, and list all the connections in the network?
### Response:
import networkx as nx

# Define partition sizes, intra-group connection probability, and inter-group connection probability
sizes = [10, 20, 30]  # three groups of sizes 10, 20, and 30
p_in = 0.5  # Nodes in the same group are connected with probability 0.5
p_out = 0.05  # Nodes of different groups are connected with probability 0.05

# Create the random partition graph
G = nx.random_partition_graph(sizes, p_in, p_out, seed=42)

# Retrieve the partition (grouping of nodes)
partition = G.graph['partition']

# Display number of nodes in the graph
print('Number of nodes:', len(G))

# Display the partition (list of node groups)
print('Partition (grouping of nodes):', partition)

# Display nodes in the graph
print('Nodes in the graph:', G.nodes())

# Display edges in the graph
print('Edges in the graph:', G.edges())
<|EOT|>
