Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
MinSTCutModule.h
Go to the documentation of this file.
1
32#pragma once
33
35#include <ogdf/basic/Graph.h>
37#include <ogdf/basic/basic.h>
39
40namespace ogdf {
41template<class E>
42class List;
43
44template<typename TCost>
46public:
51
65 virtual bool call(const Graph& graph, const EdgeArray<TCost>& weight, node s, node t,
66 List<edge>& edgeList, edge e_st = nullptr) = 0;
67
80 virtual bool call(const Graph& graph, node s, node t, List<edge>& edgeList,
81 edge e_st = nullptr) = 0;
82
83 virtual ~MinSTCutModule() { delete m_gc; }
84
92 virtual bool direction(edge e) {
94 OGDF_ASSERT(m_direction[e] != -1);
95 return m_direction[e];
96 }
97
98protected:
100 GraphCopy* m_gc = nullptr;
101
114 node source, node target, edge e_st) {
115 node gcS(gc.copy(source));
116 node gcT(gc.copy(target));
117 adjEntry adjT, adjS;
118 bool isSTplanarEmbeded(false);
119 if (gc.representsCombEmbedding()) {
120 CE.init(gc);
121 adjS = CE.findCommonFace(gcS, gcT, adjT, false);
122 isSTplanarEmbeded = (adjS != nullptr);
123 }
124 if (isSTplanarEmbeded) {
125 if (e_st == nullptr) {
126 CE.splitFace(adjS, adjT);
127 }
128 } else {
129 if (e_st == nullptr) {
130 gc.newEdge(gcS, gcT);
131 }
132 if (!planarSTEmbed(gc, gcS, gcT)) {
133 return false;
134 }
135 CE.init(gc);
136 }
137 return true;
138 }
139};
140}
Declaration of CombinatorialEmbedding and face.
Includes declaration of graph class.
Declaration of graph copy classes.
Basic declarations, included by all source files.
Class for adjacency list elements.
Definition Graph_d.h:143
Combinatorial embeddings of planar graphs with modification functionality.
void init(Graph &G)
Initializes the embedding for graph G.
edge splitFace(adjEntry adjSrc, adjEntry adjTgt, bool sourceAfter=false)
Splits a face by inserting a new edge.
adjEntry findCommonFace(const node v, const node w, bool left=true) const
Identifies a common face of two nodes and returns the respective adjacency entry.
Class for the representation of edges.
Definition Graph_d.h:364
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:390
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
Definition GraphCopy.h:463
edge newEdge(edge eOrig)
Creates a new edge (v,w) with original edge eOrig.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
int numberOfEdges() const
Returns the number of edges in the graph.
Definition Graph_d.h:982
bool representsCombEmbedding() const
Returns true iff the graph represents a combinatorial embedding.
Definition Graph_d.h:1607
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
virtual bool call(const Graph &graph, node s, node t, List< edge > &edgeList, edge e_st=nullptr)=0
The actual algorithm call.
bool preprocessingDual(const Graph &graph, GraphCopy &gc, CombinatorialEmbedding &CE, node source, node target, edge e_st)
This method preprocesses gc for minstcut calculations, by adding an st-edge if needed and embedding g...
virtual bool direction(edge e)
Returns the direction of e in the cut.
MinSTCutModule()
default constructor (empty)
virtual bool call(const Graph &graph, const EdgeArray< TCost > &weight, node s, node t, List< edge > &edgeList, edge e_st=nullptr)=0
The actual algorithm call.
EdgeArray< int > m_direction
Class for the representation of nodes.
Definition Graph_d.h:241
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
Declaration of extended graph algorithms.
bool planarSTEmbed(Graph &graph, node s, node t)
s-t-planarly embeds a graph.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
The namespace for all OGDF objects.