|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
62 template<
typename TCost>
90 if (pCost !=
nullptr) {
92 [&](
edge e) {
return (*pCost)[
copy.original(e)]; });
95 edges.quicksort(edgeCmp);
100 newOrder.quicksort(adjCmp);
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) {
257 while (sourceIt != source->adjEntries.end() && targetIt != target->adjEntries.end()) {
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())) {
The namespace for all OGDF objects.
Interface for planar subgraph algorithms.
Includes declaration of graph class.
@ Feasible
The solution is feasible.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
int find(disjoint_sets::CompressionOption< CompressionOptions::PathCompression >, int set)
Copies of graphs supporting edge splitting.
int makeSet()
Initializes a singleton set.
bool isConnected(const Graph &G)
Returns true iff G is connected.
Class for adjacency list elements.
edge theEdge() const
Returns the edge associated with this adjacency entry.
int link(disjoint_sets::LinkOption< LinkOptions::Naive >, int set1, int set2)
Maximum planar subgraph approximation algorithms by Chalermsook/Schmid and Calinescu et al.
static void copy(const T &from, T &to)
Declaration of interface for planar subgraph algorithms.
A Union/Find data structure for maintaining disjoint sets.
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.
Decralation of GraphElement and GraphList classes.
edge searchEdge(node target, node source, internal::GraphIterator< adjEntry > connectionIterator)
Finds an edge, starting at a given iterator.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
virtual PlanarSubgraphTriangles * clone() const override
Returns a new instance of the planarization module with the same settings.
node source() const
Returns the source node of the edge.
Declaration of graph copy classes.
RegisteredArray for nodes, edges and adjEntries of a graph.
Data type for general directed graphs (adjacency list representation).
bool isSimpleUndirected(const Graph &G)
Returns true iff G contains neither self-loops nor undirected parallel edges.
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.
bool m_onlyTriangles
Whether we want to only check for triangles.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
PlanarSubgraphTriangles(bool onlyTriangles=false)
Creates a planarization module based on triangle or diamond matching.
void allAdjEntries(ADJLIST &adjList) const
Returns a list with all adjacency entries of this node.
Basic declarations, included by all source files.
Implementation of disjoint sets data structures (union-find functionality).
Class for the representation of edges.
Declaration of doubly linked lists and iterators.
Declares base class for all module types.
node target() const
Returns the target node of the edge.
ReturnType
The return type of a module.
Declarations for Comparer objects.
Class for the representation of nodes.
Declaration of simple graph algorithms.
Compare elements based on a single comparable attribute.
iterator pushBack(const E &x)
Adds element x at the end of the list.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
void clear()
Removes all elements from the list.