Let's say I want write an article for adjacency list  like adjacency matrix have been written by someone else that is below shown give me Idea
Adjacency Matrix is a square matrix used to represent a finite graph. The elements of the matrix indicate whether pairs of vertices are adjacent or not in the graph. An adjacency matrix is a simple and straightforward way to represent graphs and is particularly useful for dense graphs.

Table of Content

1. Adjacency Matrix for Undirected and Unweighted graph:
2. Adjacency Matrix for Undirected and Weighted graph:
3. Adjacency Matrix for Directed and Unweighted graph:
4. Adjacency Matrix for Directed and Weighted graph:
Properties of Adjacency Matrix
Applications of Adjacency Matrix:
Advantages of Adjacency Matrix:
Disadvantages of Adjacency Matrix:
What is Adjacency Matrix?
Adjacency Matrix is a square matrix used to represent a finite graph by storing the relationships between the nodes in their respective cells. For a graph with V vertices, the adjacency matrix A is an V X V matrix or 2D array.

1. Adjacency Matrix for Undirected and Unweighted graph:
Consider an Undirected and Unweighted graph G with 4 vertices and 3 edges. For the graph G, the adjacency matrix would look like:

Adjacency-Matrix-for-Undirected-and-Unweighted-graph

Here’s how to interpret the matrix:

A[i][i] ​= 1, there is an edge between vertex i and vertex j.
A[i][i] ​= 0, there is NO edge between vertex i and vertex j.
Below is a program to create an adjacency matrix for an unweighted and undirected graph:





// C++ program to demonstrate Adjacency Matrix
// representation of undirected and unweighted graph
#include <bits/stdc++.h>
using namespace std;

void addEdge(vector<vector<int>> &mat, int i, int j)
{
    mat[i][j] = 1;
    mat[j][i] = 1; // Since the graph is undirected
}

void displayMatrix(vector<vector<int>> &mat)
{
    int V = mat.size();
    for (int i = 0; i < V; i++)
    {
        for (int j = 0; j < V; j++)
            cout << mat[i][j] << " ";
        cout << endl;
    }
}

int main()
{

    // Create a graph with 4 vertices and no edges
    // Note that all values are initialized as 0
    int V = 4;
    vector<vector<int>> mat(V, vector<int>(V, 0));

    // Now add edges one by one
    addEdge(mat, 0, 1);
    addEdge(mat, 0, 2);
    addEdge(mat, 1, 2);
    addEdge(mat, 2, 3);

    /* Alternatively we can also create using below
       code if we know all edges in advacem

     vector<vector<int>> mat = {{ 0, 1, 0, 0 },
                               { 1, 0, 1, 0 },
                               { 0, 1, 0, 1 },
                               { 0, 0, 1, 0 } }; */

    cout << "Adjacency Matrix Representation" << endl;
    displayMatrix(mat);

    return 0;
}

Output
Adjacency Matrix Representation
0 1 1 0 
1 0 1 0 
1 1 0 1 
0 0 1 0 
2. Adjacency Matrix for Undirected and Weighted graph:
Consider an Undirected and Weighted graph G with 5 vertices and 5 edges. For the graph G, the adjacency matrix would look like:

Adjacency-Matrix-for-Undirected-and-Weighted-graph

Here’s how to interpret the matrix:

A[i][j] ​= INF, then there is no edge between vertex i and j
A[i][j] ​= w, then there is an edge between vertex i and j having weight = w.
3. Adjacency Matrix for Directed and Unweighted graph:
Consider an Directed and Unweighted graph G with 4 vertices and 4 edges. For the graph G, the adjacency matrix would look like:

Adjacency-Matrix-for-Directed-and-Unweighted-graph

Here’s how to interpret the matrix:

A[i][j] ​= 1, there is an edge from vertex i to vertex j
A[i][j] ​= 0, No edge from vertex i to j.
4. Adjacency Matrix for Directed and Weighted graph:
Consider an Directed and Weighted graph G with 5 vertices and 6 edges. For the graph G, the adjacency matrix would look like:

Adjacency-Matrix-for-Directed-and-Weighted-graph

Here’s how to interpret the matrix:

A[i][j] ​= INF, then there is no edge from vertex i to j
A[i][j] ​= w, then there is an edge from vertex i having weight w