# মডিউল ১\_৫ঃ অ্যাডজাসেন্সি লিস্ট ইমপ্লিমেন্টশন

## অ্যাডজাসেন্সি লিস্ট ইমপ্লিমেন্টশন

গ্রাফের Number of nodes (n) and Number of Edges (e) ইনপুট নেয়া হল। একটি N সাইজের  array of vector delcare করা হল।

```
int n, e;
cin >> n >> e;
vector<int> mat[n];
```

e বার লুপ চালিয়ে, লুপের ভিতর edge এর নোড ২টি a and b ইনপুট নেয়া হল । এরপর অ্যারের a ইনডেক্সে থাকা vector এর মধ্যে b কে পুশ করা হল এবং একইভাবে অ্যারের b ইনডেক্সে থাকা vector এর মধ্যে a কে পুশ করা হল।&#x20;

```
 while (e--)
{
    int a, b;
    cin >> a >> b;
    mat[a].push_back(b);
    mat[b].push_back(a);
}
```

নিচের লুপটিতে অ্যারেটির 3 ইনডেক্সে থাকা vector টির মধ্যে থাকা নোড গুলোকে প্রিন্ট করা হয়েছে , সেই প্রিন্ট নোডগুলোর সাথে 3 নোডের edge রয়েছে।&#x20;

```
for (int i = 0; i < mat[3].size(); i++)
{
    cout << mat[3][i] << " ";
}
```

***

## সম্পূর্ণ কোড অ্যাডজাসেন্সি লিস্ট ইমপ্লিমেন্টশন

```
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, e;
    cin >> n >> e;
    vector<int> mat[n];
    while (e--)
    {
        int a, b;
        cin >> a >> b;
        mat[a].push_back(b);
        mat[b].push_back(a);
    }
    
    for (int i = 0; i < mat[3].size(); i++)
    {
        cout << mat[3][i] << " ";
    }
    return 0;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://phitron.gitbook.io/algorithm/module_1/_-5.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
