40#include <ogdf/basic/internal/config_autogen.h>
47class CombinatorialEmbedding;
52 const Graph* m_pGraph =
nullptr;
56 bool m_linkCopiesOnInsert =
90 void createEmpty(const
Graph& G) { setOriginalGraph(&G); }
194 node v = Graph::newNode();
195 m_vCopy[m_vOrig[v] = vOrig] = v;
199 using Graph::newNode;
207 node vOrig = m_vOrig[v];
209 if (vOrig !=
nullptr) {
210 m_vCopy[vOrig] =
nullptr;
234 m_linkCopiesOnInsert = linkCopiesOnInsert;
238 void*
preInsert(
bool copyEmbedding,
bool copyIDs,
bool notifyObservers,
bool edgeFilter,
240 int* newEdges)
override;
278 using GraphCopyBase::setOriginalGraph;
286 using GraphCopyBase::copy;
324 edge e = Graph::newEdge(m_vCopy[eOrig->
source()], m_vCopy[eOrig->
target()]);
325 m_eCopy[m_eOrig[e] = eOrig] = e;
330 using Graph::newEdge;
410 using GraphCopyBase::setOriginalGraph;
455 using GraphCopyBase::copy;
463 edge copy(
edge e)
const override {
return m_eCopy[e].empty() ? nullptr : m_eCopy[e].front(); }
476 auto& el = m_eCopy[adj->
theEdge()];
480 return el.front()->adjSource();
482 return el.back()->adjTarget();
534 using Graph::newEdge;
566 return hasAdjacentEdgesCrossings() || hasSameEdgesCrossings();
594 m_pGraph->allEdges(edgesToCheck);
595 removeNonSimpleCrossings(edgesToCheck, dualGraph);
612 edgesToCheck.
pushBack(adj->theEdge());
614 removeNonSimpleCrossings(edgesToCheck, dualGraph);
Includes declaration of dual graph class.
Includes declaration of graph class.
Decralation of GraphElement and GraphList classes.
Declaration of doubly linked lists and iterators.
Declaration of singly linked lists and iterators.
Basic declarations, included by all source files.
Class for adjacency list elements.
edge theEdge() const
Returns the edge associated with this adjacency entry.
bool isSource() const
Returns true iff this is the source adjacency entry of the corresponding edge.
Combinatorial embeddings of planar graphs with modification functionality.
A dual graph including its combinatorial embedding of an embedded graph.
Class for the representation of edges.
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
const Graph * graphOf() const
Returns the graph containing this node (debug only).
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
node target() const
Returns the target node of the edge.
node source() const
Returns the source node of the edge.
EdgeArray< edge > m_eOrig
The corresponding edge in the original graph.
const Graph * getOriginalGraph() const
GraphCopyBase(GraphCopyBase &&other) noexcept=delete
bool getLinkCopiesOnInsert() const
void nodeInserted(void *userData, node original, node copy) override
Callback notifying subclasses that insert() copied a node.
virtual adjEntry copy(adjEntry adj) const =0
Returns the adjacency entry in the graph copy corresponding to adj.
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
node original(node v) const
Returns the node in the original graph corresponding to v.
void * preInsert(bool copyEmbedding, bool copyIDs, bool notifyObservers, bool edgeFilter, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap, int *newNodes, int *newEdges) override
Callback notifying subclasses that some graph is about to be insert() -ed.
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
void init(const Graph *G)
Re-initializes the copy using G (which might be null), creating copies for all nodes and edges in G.
void delNode(node v) override
Removes node v.
NodeArray< node > m_vCopy
The corresponding node in the graph copy.
void clear() override=0
Removes all nodes and edges from this copy but does not break the link with the original graph.
void init(const Graph &G)
Re-initializes the copy using G, creating copies for all nodes and edges in G.
GraphCopyBase & operator=(GraphCopyBase &&other) noexcept=delete
virtual edge copy(edge e) const =0
Returns the edge in the graph copy corresponding to e.
virtual void setOriginalGraph(const Graph *G)=0
Re-initializes the copy using G (which might be null), but does not create any nodes or edges.
GraphCopyBase(const GraphCopyBase &other)=delete
bool isDummy(edge e) const
Returns true iff e has no corresponding edge in the original graph.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
GraphCopyBase()=default
Constructs a GraphCopyBase associated with no graph.
void setLinkCopiesOnInsert(bool linkCopiesOnInsert)
Whether insert(getOriginalGraph()) will automatically set copy and original.
void setOriginalGraph(const Graph &G)
Re-initializes the copy using G, but does not create any nodes or edges.
adjEntry original(adjEntry adj) const
Returns the adjacency entry in the original graph corresponding to adj.
edge original(edge e) const
Returns the edge in the original graph corresponding to e.
bool isDummy(adjEntry adj) const
Returns true iff adj->theEdge() has no corresponding edge in the original graph.
NodeArray< node > m_vOrig
The corresponding node in the original graph.
virtual void setOriginalEmbedding()=0
Sets the embedding of the graph copy to the embedding of the original graph.
GraphCopyBase & operator=(const GraphCopyBase &other)=delete
const Graph & original() const
Returns a reference to the original graph.
Copies of graphs supporting edge splitting.
void removeNonSimpleCrossings(SListPure< edge > &edgesToCheck, DynamicDualGraph *dualGraph=nullptr)
Removes all non-simple cossings involving edges from edgesToCheck (see hasNonSimpleCrossings() for a ...
void setOriginalGraph(const Graph *G) override
Associates the graph copy with G, but does not create any nodes or edges.
edge split(edge e) override
Splits edge e.
const List< edge > & chain(edge e) const
Returns the list of edges coresponding to edge e.
void removeEdgePathEmbedded(CombinatorialEmbedding &E, edge eOrig, FaceSet &newFaces)
Removes the complete edge path for edge eOrig while preserving the embedding.
bool hasNonSimpleCrossings() const
Returns whether the GraphCopy contains crossings that will result in a non-simple drawing.
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
void setEdge(edge eOrig, edge eCopy)
sets eOrig to be the corresponding original edge of eCopy and vice versa
void delEdge(edge e) override
Removes edge e and clears the list of edges corresponding to e's original edge.
void insertEdgePath(edge eOrig, const SList< adjEntry > &crossedEdges)
Re-inserts edge eOrig by "crossing" the edges in crossedEdges.
void removeEdgePath(edge eOrig)
Removes the complete edge path for edge eOrig.
void removeSameEdgesCrossing(adjEntry adjFirstCrossing1, adjEntry adjFirstCrossing2, adjEntry adjSecondCrossing1, adjEntry adjSecondCrossing2, DynamicDualGraph *dualGraph)
Removes the two crossings given by the adjEntries, assuming that both crossings stem from the same tw...
void edgeInserted(void *userData, edge original, edge copy) override
Callback notifying subclasses that insert() copied an edge.
void insertEdgePathEmbedded(edge eOrig, CombinatorialEmbedding &E, const SList< adjEntry > &crossedEdges)
Re-inserts edge eOrig by "crossing" the edges in crossedEdges in embedding E.
EdgeArray< ListIterator< edge > > m_eIterator
The position of copy edge in the list.
void insertEdgePath(node srcOrig, node tgtOrig, const SList< adjEntry > &crossedEdges)
Special version (for FixedEmbeddingUpwardEdgeInserter only).
void consistencyCheck() const
Asserts that this copy is consistent.
void unsplit(edge eIn, edge eOut) override
Undoes a previous split operation.
adjEntry copy(adjEntry adj) const override
Returns the adjacency entry in the copy graph corresponding to adj.
edge insertCrossing(edge &crossingEdge, edge crossedEdge, bool rightToLeft)
Inserts crossings between two copy edges.
GraphCopy(const GraphCopy &other)
void insertEdgePathEmbedded(edge eOrig, CombinatorialEmbedding &E, DynamicDualGraph &dual, const SList< adjEntry > &crossedEdges)
EdgeArray< List< edge > > m_eCopy
The corresponding list of edges in the graph copy.
void removeAdjacentEdgesCrossing(adjEntry adj1, adjEntry adj2, DynamicDualGraph *dualGraph)
Removes the crossing of the two adjacent edges adj1->theEdge() and adj2->theEdge().
void swapOriginalEdgesBetweenCrossings(adjEntry adjFirstCrossing1, adjEntry adjFirstCrossing2, adjEntry adjSecondCrossing1, adjEntry adjSecondCrossing2, DynamicDualGraph *dual=nullptr)
Swaps the original edges from adjFirstCrossing1 up to adjSecondCrossing1->theNode() with the original...
void setOriginalEmbedding() override
Sets the embedding of the graph copy to the embedding of the original graph.
void removeEdgePathEmbedded(CombinatorialEmbedding &E, DynamicDualGraph &dual, edge eOrig)
void removePseudoCrossings()
Removes all crossing nodes which are actually only two "touching" edges.
GraphCopy(const Graph &G)
void removeUnnecessaryCrossing(adjEntry adjA1, adjEntry adjA2, adjEntry adjB1, adjEntry adjB2)
void removeNonSimpleCrossings(DynamicDualGraph *dualGraph=nullptr)
Removes all non-simple cossings (see hasNonSimpleCrossings() for a definition of non-simple crossings...
void removeUnnecessaryCrossing(adjEntry adj, DynamicDualGraph *dualGraph)
Removes the pseudo crossing that adj belongs to.
void swapOriginalEdgesAtCrossing(adjEntry adjCopy1, adjEntry adjCopy2, DynamicDualGraph *dual=nullptr)
Swaps the original edges from adjCopy1 up to the common node of {adjCopy1, adjCopy2} with the origina...
bool hasAdjacentEdgesCrossings() const
Returns whether the GraphCopy contains at least one crossing of two adjacent edges.
GraphCopy(const Graph *G)
void setOriginalEdgeAlongCrossings(adjEntry adjCopy1, adjEntry adjCopy2, node vCopy, edge eOrig1, edge eOrig2)
Sets the original edges from adjCopy1 up to vCopy to eOrig2, and the original edges from adjCopy2 up ...
edge newEdge(node v, adjEntry adj, edge eOrig, CombinatorialEmbedding &E)
Creates a new edge with original edge eOrig in an embedding E.
bool isReversed(edge e) const
Returns true iff edge e has been reversed.
GraphCopy & operator=(const GraphCopy &other)
void removeNonSimpleCrossings(node origNode, DynamicDualGraph *dualGraph=nullptr)
Removes all non-simple cossings involving edges incident to origNode (see hasNonSimpleCrossings() for...
bool hasSameEdgesCrossings() const
Returns whether there are two edges in the GraphCopy that cross each other multiple times.
bool isReversedCopyEdge(edge e) const
Returns true iff e is reversed w.r.t.
edge newEdge(edge eOrig)
Creates a new edge (v,w) with original edge eOrig.
void clear() override
Removes all nodes and edges from this copy but does not break the link with the original graph.
Copies of graphs with mapping between nodes and edges.
edge newEdge(edge eOrig)
Creates a new edge in the graph copy with original edge eOrig.
GraphCopySimple & operator=(const GraphCopySimple &other)
void edgeInserted(void *userData, edge original, edge copy) override
Callback notifying subclasses that insert() copied an edge.
GraphCopySimple(const Graph &G)
void copyEmbeddingToOriginal(Graph &orig) const
Copies the current embedding back to (a non-const version of) the original graph.
void setOriginalGraph(const Graph *G) override
Re-initializes the copy using G (which might be null), but does not create any nodes or edges.
adjEntry copy(adjEntry adj) const override
Returns the adjacency entry in the graph copy corresponding to adj.
void delEdge(edge e) override
Removes edge e.
void setOriginalEmbedding() override
Sets the embedding of the graph copy to the embedding of the original graph.
GraphCopySimple(const GraphCopySimple &other)
EdgeArray< edge > m_eCopy
The corresponding edge in the graph copy.
GraphCopySimple(const Graph *G)
void clear() override
Removes all nodes and edges from this copy but does not break the link with the original graph.
edge copy(edge e) const override
Returns the edge in the graph copy corresponding to e.
Data type for general directed graphs (adjacency list representation).
Doubly linked lists (maintaining the length of the list).
Class for the representation of nodes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
const Graph * graphOf() const
Returns the graph containing this node (debug only).
Singly linked lists (maintaining the length of the list).
iterator pushBack(const E &x)
Adds element x at the end of the list.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Decralation of graph iterators.
AdjElement * adjEntry
The type of adjacency entries.
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.
void copyEmbedding(const Graph &from, Graph &to, std::function< adjEntry(adjEntry)> adjMapFromTo)