Q:

Creating permutation of vectors in c++

I'm trying to create a combination of graph edges which are stored inside a vector. I need to generate AND store the generated vectors in a vector as well. Below is what I have done so far but it is not compiling at the moment;
#include <stdlib.h>
#include<iostream>
#include<vector>
#include<algorithm>

struct edge{

int a;
int b;
int weight;
edge(int u,int v,int cost)
{
    a=u;
    b=v;
    weight=cost;
}

};

int main()
 {
  typedef std::vector<edge> V; //<or_any_class>
  V v;

    v.push_back(1,2,10);
    v.push_back(1,3,10);
    v.push_back(1,4,10);
    v.push_back(3,4,10);
    v.push_back(3,5,10);
    v.push_back(3,5,10);

  do{
        std::cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<" "<<v[3]<<" "<<v[4]<<std::endl;
    }

   while(std::next_permutation(v.begin(),v.end()));
return 0;
 }

What Im trying to get as output;

 1 2
 1 3
 1 4
 3 4
 3 5
 4 3
 1 2 1 3
 1 2 1 4

Any hints?

A:

Error one:
 v.push_back(1,2,10);

should be
 v.push_back(edge(1,2,10));
             ^^^^

Error two:
You need to define operator << for your edge class so that std::cout<<v[0] can compile
std::ostream& operator << (std::ostream& o, const edge& e)
{
     return o << e.a << " " << e.b << " " << e.weight;
}

Error three:
You need to define operator < for your egde class so that std::next_permutation(v.begin(),v.end()) can compile and work
bool operator < (const edge& e1, const edge& e2)
{
    if(e1.a != e2.a) return e1.a < e2.a;
    if(e1.b != e2.b) return e1.b < e2.b;
    return e1.weight < e2.weight; 
}

A:

This:
v.push_back(1,2,10); 

should be:
v.push_back(edge(1,2,10)); 

