62template<
typename TCost>
90 if (pCost !=
nullptr) {
99 v->allAdjEntries(newOrder);
101 copy.
sort(v, newOrder);
113 for (
edge currentEdge : edges) {
115 if (includeEdges[currentEdge]) {
123 node source = currentEdge->source();
124 node target = currentEdge->target();
126 edge triangleEdge1 =
nullptr, triangleEdge2 =
nullptr;
127 node triangleNode =
nullptr;
128 int triangleSet = -1;
134 int potentialSet = components.
find(set[v]);
135 if (potentialSet == triangleSet) {
139 if (triangleNode ==
nullptr) {
144 triangleSet = potentialSet;
149 includeEdges[currentEdge] = includeEdges[triangleEdge1] =
150 includeEdges[triangleEdge2] = includeEdges[e1] = includeEdges[e2] =
154 int sourceSet = components.
find(set[source]);
155 int targetSet = components.
find(set[target]);
157 components.
link(components.
link(sourceSet, targetSet), triangleSet),
166 for (
edge currentEdge : edges) {
167 if (includeEdges[currentEdge]) {
171 node source = currentEdge->source();
172 node target = currentEdge->target();
175 includeEdges[currentEdge] = includeEdges[e1] = includeEdges[e2] =
true;
176 int potentialSet = components.
find(set[v]);
177 int sourceSet = components.
find(set[source]);
178 int targetSet = components.
find(set[target]);
179 components.
link(components.
link(sourceSet, targetSet), potentialSet);
185 for (
edge currentEdge : edges) {
186 node source = currentEdge->source();
187 node target = currentEdge->target();
188 int sourceSet = components.
find(set[source]);
189 int targetSet = components.
find(set[target]);
190 if (sourceSet != targetSet) {
191 includeEdges[currentEdge] =
true;
192 components.
link(sourceSet, targetSet);
195 if (!includeEdges[currentEdge]) {
217 while (connectionIterator != source->
adjEntries.end()) {
218 if ((*connectionIterator)->twinNode() == target) {
219 return (*connectionIterator)->theEdge();
221 connectionIterator++;
250 int sourceSet = components.
find(set[source]);
251 int targetSet = components.
find(set[target]);
253 if (sourceSet == targetSet) {
258 if ((*sourceIt)->theEdge() == currentEdge) {
262 if ((*targetIt)->theEdge() == currentEdge) {
270 node potentialConnection;
273 || (*pCost)[copy.
original((*sourceIt)->theEdge())]
274 > (*pCost)[copy.
original((*targetIt)->theEdge())]) {
275 potentialConnector = *sourceIt;
276 potentialConnection = target;
277 potentialConnectionIterator = targetIt;
280 potentialConnector = *targetIt;
281 potentialConnection = source;
282 potentialConnectionIterator = sourceIt;
288 int potentialSet = components.
find(set[potentialNode]);
291 if (potentialSet != sourceSet && potentialSet != targetSet) {
293 searchEdge(potentialNode, potentialConnection, potentialConnectionIterator);
294 if (potentialEdge !=
nullptr) {
299 if (callback(potentialNode, potentialEdge, potentialConnector->
theEdge())) {
Implementation of disjoint sets data structures (union-find functionality).
Includes declaration of graph class.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
Declaration of doubly linked lists and iterators.
Declares base class for all module types.
Declaration of interface for planar subgraph algorithms.
Basic declarations, included by all source files.
Class for adjacency list elements.
edge theEdge() const
Returns the edge associated with this adjacency entry.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
A Union/Find data structure for maintaining disjoint sets.
int makeSet()
Initializes a singleton set.
int find(disjoint_sets::CompressionOption< CompressionOptions::PathCompression >, int set)
int link(disjoint_sets::LinkOption< LinkOptions::Naive >, int set1, int set2)
Class for the representation of edges.
node target() const
Returns the target node of the edge.
node source() const
Returns the source node of the edge.
const Graph & original() const
Returns a reference to the original graph.
Copies of graphs supporting edge splitting.
Data type for general directed graphs (adjacency list representation).
int numberOfNodes() const
Returns the number of nodes in the graph.
void sort(node v, const ADJ_ENTRY_LIST &newOrder)
Sorts the adjacency list of node v according to newOrder.
void allEdges(CONTAINER &edgeContainer) const
Returns a container with all edges of the graph.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Doubly linked lists (maintaining the length of the list).
void clear()
Removes all elements from the list.
iterator pushBack(const E &x)
Adds element x at the end of the list.
void quicksort()
Sorts the list using Quicksort.
ReturnType
The return type of a module.
@ Feasible
The solution is feasible.
Class for the representation of nodes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Interface for planar subgraph algorithms.
Maximum planar subgraph approximation algorithms by Chalermsook/Schmid and Calinescu et al.
void findTriangle(GraphCopy ©, edge currentEdge, const EdgeArray< TCost > *pCost, DisjointSets<> &components, NodeArray< int > &set, std::function< bool(node, edge, edge)> callback)
Finds all triangles from a given edge and calls a callback function on them.
edge searchEdge(node target, node source, internal::GraphIterator< adjEntry > connectionIterator)
Finds an edge, starting at a given iterator.
PlanarSubgraphTriangles(bool onlyTriangles=false)
Creates a planarization module based on triangle or diamond matching.
bool m_onlyTriangles
Whether we want to only check for triangles.
virtual PlanarSubgraphTriangles * clone() const override
Returns a new instance of the planarization module with the same settings.
virtual Module::ReturnType doCall(const Graph &graph, const List< edge > &, List< edge > &delEdges, const EdgeArray< TCost > *pCost, bool preferredImplyPlanar=false) override
Computes the set of edges delEdges which have to be deleted to obtain the planar subgraph.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
Declarations for Comparer objects.
bool isConnected(const Graph &G)
Returns true iff G is connected.
bool isSimpleUndirected(const Graph &G)
Returns true iff G contains neither self-loops nor undirected parallel edges.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.
Declaration of simple graph algorithms.
Compare elements based on a single comparable attribute.