In addition to the graph structure itself consisting of nodes and edges, information is typically associated with each node. For example, in a social network, each individual might be characterized by a fixed-length vector representing their interests. Sometimes, the edges also have information attached. For example, for a road network, each edges might be characterized by its length, number of lanes, frequency of accidents, and speed limit. The information at a node is stored in a node embedding, and the information at an edge stored in an edge embedding.
Formally, a graph consists of a set of nodes connected by a set of edges. The graph can be encoded by three matrices , representing the graph structure, node embeddings, and edge embeddings.

The graph structure is represented by the adjacency matrix . This is an matrix where each entry is set to one if there is an edge between nodes and and zero otherwise. For undirected graphs, this matrix is always symmetric. For large sparse graphs, it can be stored as a list of connections to save memory.
The -th node has an associated node embedding of length . These embeddings are concatenated and stored in the node data matrix . Similarly, the -th edge has an associated edge embedding of length . These embeddings are collected into the matrix .
Adjacency matrix properties
The adjacent matrix can be used to find the neighbors of a node using linear algebra.
Consider encoding the th node’s position as a one-hot column vector (a vector with only one non-zero entry at position , which is set to one). Wen we pre-multiply this vector by the adjacency matrix, it extracts the th column of the adjacency matrix and returns a vector with ones at the positions of the neighbors (all the places we can reach in a walk of length one from the th node). If we repeat this procedure (pre-multiply by again), the resulting vector contains the number of walks of length two from node to every node.
In general, if we raise the adjacency matrix to the power of , the entry at position of contains the number of unique walks of length from node to node . This is not the same as the number of unique paths since the walks include include routes that visit the same node more than once. Nonetheless, still contains valuable information about the graph connectivity; a non-zero entry at position indicates that the distance from to must be less than or equal to .

Permutation of node indices
Node indexing in graphs is arbitrary; permuting the node indices results in a permutation of the columns of the node data matrix and a permutation of both the rows and columns of the adjacency matrix . However, the underlying graph is unchanged; this is in contrast to images, where permuting the pixels creates a different images, and to text, where permuting the words creates a different sentence.

The operation of exchanging node indices can be expressed mathematically by a permutation matrix, . This is a matrix where exactly one entry in each row and column take the value one, and the remaining values are zero. When position of the permutation matrix is set to one, it indicates that node will become node after the permutation. To map from one indexing to another, we use the operations:
where post-multiplying by permutes the columns and pre-multiplying by permutes the rows. It follows that any processing applied to the graph should also be indifferent to these permutations (permutation-invariant). Otherwise, the result will depend on the choice of node indices.
dl
For a graph, what does adjacency matrix taken to the -th power give us?
?
The entry at position of contains the number of unique walks of length from node to node .
+++