From the course: Learning Graph Neural Networks
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Graph representations
From the course: Learning Graph Neural Networks
Graph representations
- [Instructor] We've looked at a few different types of graphs and understood what kind of real world entities and relationships those graphs could be used to model. But how do you represent a graph programmatically? It turns out that there are three ways to represent graphs in code, adjacency matrices, adjacency lists, and adjacency sets. Let's discuss each of these in turn, starting with the adjacency matrix to represent a graph. If you have N nodes in a graph, the adjacency matrix is an N by N matrix where every row and every column in the matrix represents a node in your graph. In the first part of this example, I'm going to discuss the adjacency matrix representation for a directed graph, but this applies equally well to undirected graphs as well. Here is a graph that we are going to represent using a matrix. Our graph has five nodes and have set up matrix off to the right, which contains five rows and five columns. Every node has a corresponding row and a corresponding column…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.