Techno Blender
Digitally Yours.

Adjacency List meaning & definition in DSA

0 40


Improve Article

Save Article

Like Article

Improve Article

Save Article

Like Article

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.

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?

Like Article

Save Article


Improve Article

Save Article

Like Article

Improve Article

Save Article

Like Article

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.

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?

Like Article

Save Article

FOLLOW US ON GOOGLE NEWS

Read original article here

Denial of responsibility! Techno Blender is an automatic aggregator of the all world’s media. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – [email protected]. The content will be deleted within 24 hours.
Leave a comment