I’m using OGDF version 2012.07.
I have a GraphCopy which represents a copy of a Graph instance. It holds references to the original nodes and edges when operating on the graph copy. In the documentation of GraphCopy, it says:
Copies of graphs supporting edge splitting.
The class GraphCopy represents a copy of a graph and maintains a mapping between the nodes and edges of the original graph to the copy and vice versa.
[…]
There is a method ogdf::GraphCopy::newEdge(edge eOrig) which is documented as follows:
Creates a new edge (v,w) with original edge eOrig.
The method is implemented as follows:
edge GraphCopy::newEdge(edge eOrig)
{
OGDF_ASSERT(eOrig != 0 && eOrig->graphOf() == m_pGraph);
OGDF_ASSERT(m_eCopy[eOrig].empty()); // no support for edge splitting!
edge e = Graph::newEdge(m_vCopy[eOrig->source()], m_vCopy[eOrig->target()]);
m_eCopy[m_eOrig[e] = eOrig].pushBack(e);
return e;
}
In the second assertion, the number of associated edge copies of the edge eOrig in the original graph has to be zero, which is only possible when the edge copy has been deleted, since initially (when the GraphCopy was initialized with an original graph) all edges in the graph copy are associated with the corresponding original edge in the original graph; thus, m_eCopy[eOrig].empty() is false for all edges.
How am I supposed to duplicate an edge in the graph copy while not changing the original graph?
I can not follow your explanations about the implementation. When I browse the source code GraphCopy.h on the OGDF website (which says its for 2012.07.), I see totally different classes. There is one class GraphCopy (which is an interface for derrived GraphCopy classes supporting edge splitting) and another class GraphCopySimple which doesn’t support edge spliting.
So my advice is to check if you really have the right version.
The method newEdge(edge eOrig) in GraphCopySimple looks like it does what you want:
But there is one issue remaining. GraphCopySimple has no implementation for the constructors, so I guess it meant as abstract base class, so you need to derive your own GraphCopy-class and implement the missing functions.