<｜begin▁of▁sentence｜>### Instruction:
Two social networks representing connections within different communities use stochastic block models to generate their structures. Each network consists of 100 nodes divided evenly into two groups. The connectivity probabilities within and between these groups differ across the networks. A researcher aims to statistically compare these networks to determine whether the edge probabilities between corresponding groups are significantly different under the assumption of a stochastic block model. The analysis can reveal structural differences in community integration between the two networks.
### Response:
import numpy as np
from graspologic.inference import group_connection_test
import networkx as nx
from graspologic.simulations import sbm

# Generate two graphs using stochastic block models (SBM)
n_communities = [50, 50] # Two communities, each with 50 nodes
p_matrix1 = [[0.5, 0.05], [0.05, 0.5]] # Probability matrix for graph 1
p_matrix2 = [[0.75, 0.01], [0.01, 0.75]] # Probability matrix for graph 2

G1 = sbm(n_communities, p_matrix1)
G2 = sbm(n_communities, p_matrix2)

# Convert to adjacency matrices
A1 = nx.to_numpy_array(G1)
A2 = nx.to_numpy_array(G2)

# Group labels for the nodes in each graph
labels1 = [0] * 50 + [1] * 50
labels2 = [0] * 50 + [1] * 50

# Perform the group_connection_test
result = group_connection_test(A1, A2, labels1, labels2)
print(f'Statistic: {result.stat}')
print(f'P-value: {result.pvalue}')
<|EOT|>
