<｜begin▁of▁sentence｜>### Instruction:
We have two random graphs, each with 50 nodes. Our goal is to analyze and visually compare their structures. To achieve this, we want to use spectral embedding to represent each graph in a lower-dimensional space and then align these embeddings to find an optimal match between the structures of the two graphs. How can we use the SeedlessProcrustes module from graspologic to align these spectral embeddings and visualize the results?
### Response:
import numpy as np
from graspologic.align import SeedlessProcrustes
import matplotlib.pyplot as plt
import networkx as nx

# Step 1: Generate two random graphs with 50 nodes each
G1 = nx.gnm_random_graph(n=50, m=200)
G2 = nx.gnm_random_graph(n=50, m=200)

# Step 2: Obtain the adjacency matrices
A1 = nx.to_numpy_array(G1)
A2 = nx.to_numpy_array(G2)

# Step 3: Perform spectral embedding to get lower-dimensional representations
embedder = graspologic.embed.AdjacencySpectralEmbed()
X = embedder.fit_transform(A1)
Y = embedder.fit_transform(A2)

# Step 4: Align the embeddings using SeedlessProcrustes
aligner = SeedlessProcrustes()
X_aligned = aligner.fit_transform(X, Y)

# Step 5: Visualize the aligned embeddings
plt.scatter(X_aligned[:, 0], X_aligned[:, 1], c='red', label='Graph 1')
plt.scatter(Y[:, 0], Y[:, 1], c='blue', label='Graph 2', marker='x')
plt.legend()
plt.title('Aligned Graph Embeddings')
plt.show()
<|EOT|>
