Horje
Adjacency List meaning & definition in DSA

An adjacency list is a data structure used to represent a graph where each node in the graph stores a list of its neighboring vertices.

Graph representation of Directed Graph to Adjacency List

Characteristics of the Adjacency List:

  • The size of the matrix is determined by the number of nodes in the network.
  • The number of graph edges is easily computed.
  • The adjacency list is a jagged array.

How to build an Adjacency List?

It is very easy and simple to construct an adjacency list for a graph there are certain steps given below that you need to follow:

  • Create an array of linked lists of size N, where N is the number of vertices in the graph.
  • Create a linked list of adjacent vertices for each vertex in the graph.
  • For each edge (u, v) in the graph, add v to the linked list of u, and add u to the linked list of v if the graph is undirected otherwise add v to the list of u if it is directed from u to v. (In case of weighted graphs store the weight along with the connections).

Applications of the Adjacency List:

Advantages of using an Adjacency list:

  • An adjacency list is simple and easy to understand.
  • Adding or removing edges from a graph is quick and easy.

Disadvantages of using an Adjacency list:

  • In adjacency lists accessing the edges can take longer than the adjacency matrix.
  • It requires more memory than the adjacency matrix for dense graphs.

What else can you read?




Reffered: https://www.geeksforgeeks.org


DSA

Related
Generic Tree meaning & definition in DSA Generic Tree meaning & definition in DSA
Increase A by atmost B times so that zeroes at the end of A are maximized Increase A by atmost B times so that zeroes at the end of A are maximized
Find the maximum sum of diagonals for each cell of the Matrix Find the maximum sum of diagonals for each cell of the Matrix
Make elements of Array equal by repeatedly dividing elements by 2 or 3 Make elements of Array equal by repeatedly dividing elements by 2 or 3
Minimizing Array sum with groupings Minimizing Array sum with groupings

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
13