Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

MinSTCutModule.h
Go to the documentation of this file.
1 
32 #pragma once
33 
36 
37 namespace ogdf {
38 
39 template<typename TCost>
41 public:
46 
60  virtual bool call(const Graph &graph, const EdgeArray<TCost> &weight, node s, node t, List<edge> &edgeList,
61  edge e_st = nullptr) = 0;
62 
75  virtual bool call(const Graph &graph, node s, node t, List<edge> &edgeList, edge e_st = nullptr) = 0;
76 
77  virtual ~MinSTCutModule() {
78  delete m_gc;
79  }
80 
88  virtual bool direction(edge e) {
90  OGDF_ASSERT(m_direction[e] != -1);
91  return m_direction[e];
92  }
93 
94 protected:
96  GraphCopy *m_gc = nullptr;
97 
109  bool preprocessingDual(const Graph &graph,
110  GraphCopy &gc,
112  node source,
113  node target,
114  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 }
void init(Graph &G)
Initializes the embedding for graph G.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
Definition: GraphCopy.h:335
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
Declaration of CombinatorialEmbedding and face.
bool planarSTEmbed(Graph &graph, node s, node t)
s-t-planarly embeds a graph.
bool representsCombEmbedding() const
Returns true iff the graph represents a combinatorial embedding.
Definition: Graph_d.h:1164
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. ...
edge newEdge(edge eOrig)
Creates a new edge (v,w) with original edge eOrig.
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.
int numberOfEdges() const
Returns the number of edges in the graph.
Definition: Graph_d.h:601
Class for the representation of edges.
Definition: Graph_d.h:292
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:249
Class for the representation of nodes.
Definition: Graph_d.h:169
MinSTCutModule()
default constructor (empty)
EdgeArray< int > m_direction
edge splitFace(adjEntry adjSrc, adjEntry adjTgt)
Splits a face by inserting a new edge.
The namespace for all OGDF objects.
Declaration of extended graph algorithms.
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.
Combinatorial embeddings of planar graphs with modification functionality.
Class for adjacency list elements.
Definition: Graph_d.h:79
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41