This is how I've defined my graph. This is not a typical graph, it is specific to the type of problem I'm dealing with.
class Vertex;
class Edge
{
public:
Vertex *org;
Vertex *dest;
bool dir;
};
struct Vertex{
int id;
vector<Edge> edges;
int weight;
};
struct Graph{
vector<Vertex> vertices;
};
I'm having problem in adding a vertex in the graph. This is how I'm doing it
Graph* graph1;
Vertex* first = addVertex(0);
graph1->vertices.push_back(*first);
The addVertex function is working properly, but if you still want to refer, here it is
Vertex* addVertex(int id){
Vertex*newVertex = new Vertex;
newVertex->id=id;
newVertex->weight=0;
return newVertex;
}
The function stops working just before graph1->vertices.push_back(*first);