title: Generating an edge graph using four values a,b,c,d in c++
body: <p>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 &lt;-&gt; ((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 ?</p>
  <p>Here is the code :</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  struct Edge {
      int src, dest;
  };
  class Graph
  {
  public:
      vector&lt;vector&lt;int&gt;&gt; adjList;
      Graph(vector&lt;Edge&gt; const&amp; edges, int N)
      {
          adjList.resize(N);
          for (auto&amp; edge : edges)
          {
              adjList[edge.src].push_back(edge.dest);
          }
      }
  };
  void printGraph(Graph const&amp; graph, int N)
  {
      for (int i = 0; i &lt; N; i++)
      {
          cout &lt;&lt; i &lt;&lt; &quot; ——&gt; &quot;;
          for (int v : graph.adjList[i])
          {
              cout &lt;&lt; v &lt;&lt; &quot; &quot;;
          }
          cout &lt;&lt; endl;
      }
  }
  int main()
  {
      vector&lt;Edge&gt; edges;
      int a, b, c, d,remainder,Nodges,result;
      cout &lt;&lt; &quot;Enter 4 values : \n&quot;;
      cin &gt;&gt; a &gt;&gt; b &gt;&gt; c &gt;&gt; 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 &lt; Nodges; i++)
      {
          for (int j = 0; j &lt; Nodges; j++)
          {
              result = ((a * i + b * j) / c) % d;
              if (result &lt;= 1)
              {
                  edges =
                  {
                      {i,j}
                  };
              }
          }
      }
      Graph graph(edges, Nodges);
      printGraph(graph, Nodges);
      return 0;
  }
  </code></pre>