Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

MinSTCutModule.h
Go to the documentation of this file.
1 
32 #pragma once
33 
35 #include <ogdf/basic/Graph.h>
36 #include <ogdf/basic/GraphCopy.h>
37 #include <ogdf/basic/basic.h>
39 
40 namespace ogdf {
41 template<class E>
42 class List;
43 
44 template<typename TCost>
46 public:
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 
98 protected:
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 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
Graph.h
Includes declaration of graph class.
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::ConstCombinatorialEmbedding::findCommonFace
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.
Definition: CombinatorialEmbedding.h:371
ogdf::MinSTCutModule::direction
virtual bool direction(edge e)
Returns the direction of e in the cut.
Definition: MinSTCutModule.h:92
ogdf::MinSTCutModule::preprocessingDual
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...
Definition: MinSTCutModule.h:113
extended_graph_alg.h
Declaration of extended graph algorithms.
ogdf::GraphCopy
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:391
ogdf::CombinatorialEmbedding::splitFace
edge splitFace(adjEntry adjSrc, adjEntry adjTgt, bool sourceAfter=false)
Splits a face by inserting a new edge.
ogdf::planarSTEmbed
bool planarSTEmbed(Graph &graph, node s, node t)
s-t-planarly embeds a graph.
Definition: extended_graph_alg.h:331
ogdf::GraphCopy::newEdge
edge newEdge(edge eOrig)
Creates a new edge (v,w) with original edge eOrig.
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:142
ogdf::MinSTCutModule::call
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.
ogdf::Graph::numberOfEdges
int numberOfEdges() const
Returns the number of edges in the graph.
Definition: Graph_d.h:985
ogdf::MinSTCutModule::m_direction
EdgeArray< int > m_direction
Definition: MinSTCutModule.h:99
ogdf::CombinatorialEmbedding::init
void init(Graph &G)
Initializes the embedding for graph G.
Definition: CombinatorialEmbedding.h:464
ogdf::MinSTCutModule::~MinSTCutModule
virtual ~MinSTCutModule()
Definition: MinSTCutModule.h:83
ogdf::MinSTCutModule
Definition: MinSTCutModule.h:45
GraphCopy.h
Declaration of graph copy classes.
ogdf::List< edge >
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::GraphCopy::copy
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
Definition: GraphCopy.h:464
ogdf::Graph::representsCombEmbedding
bool representsCombEmbedding() const
Returns true iff the graph represents a combinatorial embedding.
Definition: Graph_d.h:1609
ogdf::MinSTCutModule::m_gc
GraphCopy * m_gc
Definition: MinSTCutModule.h:100
basic.h
Basic declarations, included by all source files.
CombinatorialEmbedding.h
Declaration of CombinatorialEmbedding and face.
ogdf::CombinatorialEmbedding
Combinatorial embeddings of planar graphs with modification functionality.
Definition: CombinatorialEmbedding.h:406
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::MinSTCutModule::MinSTCutModule
MinSTCutModule()
default constructor (empty)
Definition: MinSTCutModule.h:50
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716