I have a C++ problem here.
I have three classes: Graph, Nodes and Edges, to model a simple Graph. Now an object of the Graph class has a vector with objects of the Node class and a vector with objects of the Edge class.
An object of the Node class has to know all incoming and outgoing edges. And an object of the edge class has to know from which node it comes and to which node it goes. Now i have the following problem: All edges in the graph are stored in the vector in the edge class. Objects of the node class have to know some edges as well, so I gave them a vector of pointer to point to the belonging edges in the vector of the graph. But my problem is now: If I remove an edge from the vector of the graph the pointers are wrong.
I don't want to copy eache edge into two vectors, so i think i have to do this that way but I really see the problem of removing something from the vector.
Is there a solution or do I have to copy each edge? Could someone help me please?
std::list?