UMAP reduces high-dimensional embeddings to two or three dimensions for visual analysis, keeping similar nodes near one another while retaining broader structural relationships. section 2.1.3
A practical graph-embedding workflow uses UMAP as a visualization stage:
- Generate node embeddings with Node2Vec, convert them to a numerical array, and fit UMAP with a chosen number of components. section 2.1 section 2.1.3
- Tune n_neighbors to balance local detail against broader structure, and use min_dist to influence how closely points can cluster. section 2.1.3
- Plot the resulting two-dimensional coordinates and use node colors or shapes to inspect possible clusters and relationships. section 2.1.3
Political Books graph
Applying UMAP to Node2Vec embeddings of 105 political books and 441 co-purchase edges reveals potential clusters associated with liberal, conservative, and neutral political leanings. section 2.1 section 2.1.3
Listing 2.2 Visualizing the embeddings using UMAP
node_embeddings = [embeddings[str(node)] \ for node in gml_graph.nodes()] #1 node_embeddings_array = np.array(node_embeddings) umap_model = umap.UMAP(n_neighbors=15, min_dist=0.1, n_components=2, \ random_state=42) umap_features = umap_model.fit_transform\ (node_embeddings_array) #2 plt.scatter(umap_features[:, 0], \ umap_features[:, 1], color=node_colors, alpha=0.7) #3
The implementation initializes UMAP with 15 neighbors, a 0.1 minimum distance, two components, and a fixed random state before plotting the transformed coordinates. section 2.1.3


