title: How do i push back the new input of constructor to the default input of the constructor in C++?
body: <p>I have a class to implement graph in c++ as below. This is the default coding and it cannot be modified.</p>
  
  <pre><code>Graph(vector&lt;Edge&gt; const &amp;edges, int N)
  {
      // construct a vector of vectors of Pairs to represent an adjacency list
      vector&lt;vector&lt;Pair&gt; &gt; adjList;
      // resize the vector to N elements of type vector&lt;Pair&gt;
      adjList.resize(N);
  
      // add edges to the directed graph
      for (auto &amp;edge: edges)
      {
          int src = edge.src;
          int dest = edge.dest;
          int weight = edge.weight;
  
          // insert at the end
          adjList[src].push_back(make_pair(dest, weight));
      }
  
      this-&gt;N = N;
  }
  </code></pre>
  
  <p>In the main program, i have the default input for the constructor as below. I have to check whether the graph has a cycle or not. If it does not, the program has to generate random edges until cycle is found in the graph. The default graph does not contain cycle and it has the edges as below:</p>
  
  <pre><code>vector&lt;Edge&gt; edges =
      {
          // (x, y, w) -&gt; edge from x to y having weight w
          { 0,1,6 }, { 0,2,12 }, { 1,4,9 }, { 3,4,1 }, { 3,2,4 }
      };
  </code></pre>
  
  <p>I tried appending the random edges to the default graph using the code below. However,it does not work.</p>
  
  <pre><code>do
  {
    src=rand()%5;
    dest=rand()%5;
    weight=rand()%20;
  
    vector&lt;Edge&gt; edges1{
      {src, dest, weight}};
  
    Graph graph1(edges1,N);
    graph.push_back(graph1);
  
    if(graph.isCyclic())
    {
      //print the graph
    }
  }while(!graph.isCyclic());
  </code></pre>
  
  <p>I think the push_back() function is not used properly. Anyone knows how? Thanks.</p>