Adjacency list representation of graph
A graph is a non-linear data structure that is used to represent networks, connections, and relationships between various entities. Graphs consist of nodes (also known as vertices) and edges (also known as links or arcs), where nodes represent entities and edges represent connections or relationships between entities. Graphs are used in a wide range of applications such as social networks, transportation networks, computer networks, and many more.
There are two types of graphs: directed graphs and undirected graphs. In a directed graph, edges have a direction associated with them, while in an undirected graph, edges do not have any direction associated with them.
Adjacency List Representation:
The adjacency list is one of the most commonly used data structures to represent a graph. An adjacency list is an array of linked lists, where each element of the array represents a node in the graph, and the linked list associated with the element contains the nodes that are adjacent to the node represented by that element.
In other words, each element of the array stores a list of nodes that are directly connected to the node represented by that element. The adjacency list representation is more space-efficient than the adjacency matrix representation for sparse graphs.
This article is based on Adjacency list.
Directed Graph Adjacency list

Here given code implementation process.
-
1) Adjacency list representation of directed graph in c
2) Adjacency list representation of directed graph in cpp
3) Adjacency list representation of directed graph in java
4) Adjacency list representation of directed graph in c#
5) Adjacency list representation of directed graph in php
6) Adjacency list representation of directed graph in golang
7) Adjacency list representation of directed graph in kotlin
8) Adjacency list representation of directed graph in swift
9) Adjacency list representation of directed graph in scala
10) Adjacency list representation of directed graph in python
11) Adjacency list representation of directed graph in ruby
12) Adjacency list representation of directed graph in typescript
13) Adjacency list representation of directed graph in node js
14) Adjacency list representation of directed graph in vb.net
Un-Directed Graph Adjacency list

-
1) Adjacency list representation of undirected graph in java
2) Adjacency list representation of undirected graph in c
3) Adjacency list representation of undirected graph in c++
4) Adjacency list representation of undirected graph in go
5) Adjacency list representation of undirected graph in csharp
6) Adjacency list representation of undirected graph in vb.net
7) Adjacency list representation of undirected graph in php
8) Adjacency list representation of undirected graph in node js
9) Adjacency list representation of undirected graph in typescript
10) Adjacency list representation of undirected graph in python
11) Adjacency list representation of undirected graph in ruby
12) Adjacency list representation of undirected graph in scala
13) Adjacency list representation of undirected graph in swift
14) Adjacency list representation of undirected graph in kotlin
Note that in both example first use an array which are contain actual node values. Array is useful to get any node quickly in existing array. When graph nodes are not predefined or you are remove existing graph node then array are not suitable here.
Because after create array, In most of programming language are not allowing to resize the array size such as add or delete existing node. In this case you'll can use linked list to storing the value of actual graph node.
Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.
New Comment