Any graph is fully specified by its adjacency matrix.
- Undirected graphs always have a symmetric adjecency matrix, the identity is all nodes having only a connection to themselves.
- All 1s in show the one-step connections to a node.
- The values on the diagonal in are the number of connections node has (degree).
- Other values of show the two-step connections node has with node .
Generally: shows the how many -step paths there are from node back to itself on the diagonal - or generally - how many paths of length from node to node (not unique; nodes can be visited multiple times, etc.). See also: matrix exponential & communicability!
A non-zero entry at position (, ) indicates that the distance from to must be less than or equal to .
Not sure what I did here… some example from the UDL book, ig.
There are many adjacency matrices that can encode the same connectivity.
This is the case when there is no natural order for the nodes, and is an issue for neural networks which are not permutation invariant.
Every adjacency matrix that can describe this small graph of only 4 nodes: ()
adjacency list
Link to originalAdjacency list
Adjacency matrices are usually quite sparse, wasting space and compute.
We can instead also store the graph as an adjacency list, where we store tuples of , the -th entry describing the edge between nodes and .In other words, it grows with the number of existing edges rather than the number of possible edges!
This format is also permutation invariant!
References
UDL book
https://distill.pub/2021/gnn-intro/