I saw several questions discussion the benefits of adjacency lists over matrices to represent a sparse undirected graph. On the other hand, none of them discuss sparse matrix representations such as scipy's coo or csr formats.
Do adjacency lists still provide benefits in this case?
Definitions of the above:
- Adjacency list: a graph is represented as a dictionary, where each vertex is associated to the list of its neighbors (and the value of the edge): {i: [(neigh_1, val1), (neigh2, val_2)]}. Suppose these lists are linked lists ;
cooformat: the graph is represented as a dictionary of edges: (i,j) -> value.csrformat: the matrix is stored row-wise. For each non-zero row, we have 2 arrays: indices[i] and values[i]. Example: indices[i] = [neigh_1, neigh_2], values[i] = [neigh1, neigh2].
Related: When are adjacency lists or matrices the better choice? and https://stackoverflow.com/questions/2218322/what-is-better-adjacency-lists-or-adjacency-matrices-for-graph-problems-in-c/5419933#5419933