UUtah Data Mining | F26 | L23 : Embeddings of Graphs
Overview
Graph embeddings map graph vertices into vectors so methods such as clustering and classification can work with connectivity data. The lecture contrasts a weak classical MDS approach based on binary adjacency distances with Laplacian eigenvector embeddings, then explains how DeepWalk and Node2Vec use random-walk neighborhoods and stochastic gradient descent to learn richer representations.
Key takeaways
- Binary adjacency distances assign zero distance to connected vertices, so classical MDS on 1 − A can collapse nodes and fail to preserve useful graph structure.
- The graph Laplacian combines adjacency and degree information: L₀ = D − A, while the normalized form is I − D⁻¹ᐟ² A D⁻¹ᐟ².
- DeepWalk and Node2Vec use random-walk context windows to capture higher-order neighborhoods, with practical window sizes often around 3 to 5 nodes on either side.
- Random-walk neighborhoods can be treated like word contexts: walks form sequences, vertices act like tokens, and embedding dot products are trained to reflect neighborhood similarity.
- Embedding dimension trades representational flexibility against storage: small graphs may use fewer than 10 dimensions, while larger networks may need hundreds.
- Two-dimensional graph layouts become unreliable at scale: force-directed drawings may help around 100 nodes, but graphs near 1,000 nodes can already be difficult to read.
Chapters
- The lecture introduces graph embeddings as a way to represent each graph vertex in a vector space.
- Possible vertices include web pages, people, companies, products, and songs, with edges encoding their connections.
- The planned ethics activity uses word embeddings, described as roughly 50,000 English words represented by 300-dimensional vectors.
- Embeddings can enable familiar downstream methods such as clustering and classification when the available data is only connections between nodes.
- Setting similarity to 1 for an edge and 0 for no edge, then converting it to distance, makes connected nodes have zero distance.
- That binary edge-based distance is too crude to preserve meaningful graph structure.
- A graph with n vertices can have up to n choose 2 edges, which grows roughly as n squared.
- Many practical graphs are sparse, with examples including about n log n edges or n to the power 1.1.
- An adjacency matrix A stores Aᵢⱼ = 1 when vertices i and j share an edge and 0 otherwise, while practical inputs often store only existing edges as pairs of vertex indices.
- The proposed baseline converts adjacency values into distances using Dᵢⱼ = 1 − Aᵢⱼ.
- Classical multidimensional scaling double-centers the squared distance matrix, then uses selected eigenvectors and eigenvalues to form coordinates.
- Because adjacent vertices receive distance zero, the method can collapse connected nodes together and produce a poor embedding.
- The degree matrix D is diagonal, with Dᵢᵢ equal to the number of edges incident to vertex i.
- The unnormalized graph Laplacian is L₀ = D − A; the normalized Laplacian is I − D⁻¹ᐟ² A D⁻¹ᐟ².
- Embedding with Laplacian eigenvectors and eigenvalues handles graph structure more effectively than the binary-distance MDS baseline.
- Laplacian embeddings capture connectivity patterns and connect conceptually to spectral clustering, though the lecture notes that random-walk methods are more widely used in recent practice.
- DeepWalk and Node2Vec generate graph representations by sampling walks that repeatedly choose a neighboring vertex.
- For the lecture’s examples, the graph is undirected, so a walk can return along an edge; directed-graph methods require additional considerations.
- Random walks provide a way to capture more than immediate adjacency, while the embedding dimension can be chosen for the task.
- A neighborhood window of size L considers up to L nodes before and after a target vertex in a walk; the example uses L = 2, while practical values are often 3 to 5.
- Across many sampled paths, a node’s context represents how often other vertices appear near it, yielding a sparse neighborhood-probability vector.
- The method adapts the context-window idea from word embeddings: random walks act like sentences and graph vertices act like tokens.
- The training objective makes embedding dot products approximate similarities derived from the nodes’ random-walk neighborhoods.
- Stochastic gradient descent adjusts node vectors to match the neighborhood-based similarity objective, and can be parallelized on GPUs.
- The lecture gives roughly 50 dimensions as a useful scale for many laptop-sized graphs; graphs with a few thousand nodes may need fewer than 10 dimensions, while large networks may require hundreds.
- Higher dimensions provide more degrees of freedom for optimization but increase the memory required to store node vectors.
- Learned graph embeddings can feed classifiers and other machine-learning methods for node analysis.
- Large graph drawings often become a dense “hairball,” making visual inspection difficult.
- Force-directed layouts, which model edges as springs and optimize node positions, can work reasonably well for graphs around 100 nodes and become hard to interpret near 1,000.
- For graphs with tens of thousands or millions of nodes, the lecture recommends analysis through embeddings and classifiers rather than relying on a 2D drawing.
Transcript excerpt
0:32 Uh so welcome everyone. So let's get started. Um so uh um so today we are switching to the last uh um so section of class on graph u um so on graph structured data. We're going to start with talking about graph embeddings. This is how to um how to take a graph and then represent the nodes again in some vector space. and we'll kind of survey a variety of uh uh of approaches here. Um so the hope is all the approaches will seem familiar at this point in the class. Um and so um so if you use in practice, you'll probably use some library to do
1:19 it. So we won't have to go into um so too much detail here. Then the second half of the co of this lecture will be doing an ethics activity. Um so is here um and so he'll be handing out some sheets for you to work through through small groups. Um oh let me I wanted to pull this up QR code. Um, and yeah. So, let's see. So, there's a QR code of a link to a website. I will tell you that. Um, so this is also on in of also posted on Canvas. I'm posting it
2:10 here because it takes a few minutes to load because it's uh um so it's pretty large. It's going to be um loading a kind of uh some large number of words in English language. I don't know if it's 50,000 or um each in a 300dimensional vector. So, you'll want to get this on uh uh onto your laptop and it will take a few minutes to load on your laptop and your laptop will be kind of starve for for memory while you're using it. Okay? So, you don't necessarily need to do it
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, UofU Data Science.