Graph Representation (Adjacency Matrix)

PHOTO EMBED

Fri Jun 07 2024 12:56:59 GMT+0000 (Coordinated Universal Time)

Saved by @ayushg103 #c++

#include<bits/stdc++.h>
using namespace std;
const int N = 1e3+5;
int graph[N][N];
int main()
{
    int v,e,j,k;
    cin>>v>>e;
    for(int i=0;i<e;++i)
    {
        cin>>j>>k;
        graph[i][j]=1;
        graph[j][i]=1;
        
    }
}
content_copyCOPY

It takes so much space(O(N^2))