I'm having a trouble solving a question which asks me to generate an edge graph using 4 random numbers a,b,c,d , so the formula is as follows , to generate the nodges of the graph we'll use variable d , if we divide d with 3 and we get a remainder of 0 then 10 nodges are generated , if d/3 = 1 then 11 nodges if d/3 = 2 then 12 nodges are generated , as for the edges we have the following formula (i,j) ∈ U <-> ((ai+bj)/c) / d ≤ 1 , basically the edge will connect the nodge of i with the nodge of j if the formula after dividing by d gives a remainder smaller or equal to 1. Can someone tell me what's the problem with the code below ?
Here is the code :
#include <iostream>
#include <vector>
using namespace std;
struct Edge {
    int src, dest;
};
class Graph
{
public:
    vector<vector<int>> adjList;
    Graph(vector<Edge> const& edges, int N)
    {
        adjList.resize(N);
        for (auto& edge : edges)
        {
            adjList[edge.src].push_back(edge.dest);
        }
    }
};
void printGraph(Graph const& graph, int N)
{
    for (int i = 0; i < N; i++)
    {
        cout << i << " ——> ";
        for (int v : graph.adjList[i])
        {
            cout << v << " ";
        }
        cout << endl;
    }
}
int main()
{
    vector<Edge> edges;
    int a, b, c, d,remainder,Nodges,result;
    cout << "Enter 4 values : \n";
    cin >> a >> b >> c >> d;
    remainder = d % 3;
    if (remainder == 0)
    {
        Nodges = 10;
    }
    else if (remainder == 1)
    {
        Nodges = 11;
    }
    else if (remainder == 2)
    {
        Nodges = 12;
    }
    for (int i = 0; i < Nodges; i++)
    {
        for (int j = 0; j < Nodges; j++)
        {
            result = ((a * i + b * j) / c) % d;
            if (result <= 1)
            {
                edges =
                {
                    {i,j}
                };
            }
        }
    }
    Graph graph(edges, Nodges);
    printGraph(graph, Nodges);
    return 0;
}
 
    