the other way to represent graph is by using an adjacency list an adjacency list is an array of separate lists each element of the array ai is listwhich contains all the vertices that are adjacent to vertex for weighted graphthe weight or cost of the edge is stored along with the vertex in the list using pairs in an undirected graphif vertex is in list ai then vertex will be in list aj the space complexity of adjacency list is ( ebecause in an adjacency list information is stored only for those edges that actually exist in the graph in lot of caseswhere matrix is sparse using an adjacency matrix may not be very useful this is because using an adjacency matrix will take up lot of space where most of the elements will be anyway in such casesusing an adjacency list is better notea sparse matrix is matrix in which most of the elements are zerowhereas dense matrix is matrix in which most of the elements are non-zero consider the same undirected graph from an adjacency matrix the adjacency list of the graph is as followsa