Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

PlanarSeparatorModule.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
35 #include <ogdf/basic/GraphCopy.h>
38 
39 #include <map>
40 #include <memory>
41 #include <set>
42 
43 namespace ogdf {
44 namespace planar_separators {
45 
50 public:
51  virtual ~BFSTree() = default;
52 
57  virtual GraphCopy* getGraph() const = 0;
58 
63  virtual node getRoot() const = 0;
64 
69  virtual int getGraphSize() const = 0;
70 
77  virtual bool isInTree(edge e) const = 0;
78 
85  virtual int getLevelOfNode(node n) const = 0;
86 
93  virtual node getParentOfNode(node n) const = 0;
94 
101  virtual int getDescendantsOfNode(node n) const = 0;
102 
109  virtual List<node> getChildrenOfNode(node n) const = 0;
110 
117  virtual adjEntry getAdjToParent(node n) const = 0;
118 };
119 
124 public:
131  ArrayBFSTree(GraphCopy& G, node rootNode) : pGraph {&G}, root {rootNode} { init(); }
132 
136  void init() {
137  // init arrays
138  levelOfNode.init(*pGraph, -1);
139  parentOfNode.init(*pGraph, nullptr);
140  childrenOfNode.init(*pGraph);
141  edgeToParent.init(*pGraph, nullptr);
142  descendantsOfNode.init(*pGraph,
143  1); // number of descendants of a node, the node itself counts as its own descendant
144  inTree.init(*pGraph, false);
145  mark.init(*pGraph, false); // records if that node was visited by BFS
146 
147  // mark root node
148  mark[root] = true;
149  }
150 
151  GraphCopy* getGraph() const override { return pGraph; }
152 
153  node getRoot() const override { return root; }
154 
155  int getGraphSize() const override {
156  OGDF_ASSERT(pGraph != nullptr);
157  return pGraph->numberOfNodes();
158  }
159 
160  bool isInTree(edge e) const override { return inTree[e]; }
161 
162  int getLevelOfNode(node n) const override { return levelOfNode[n]; }
163 
164  node getParentOfNode(node n) const override { return parentOfNode[n]; }
165 
166  int getDescendantsOfNode(node n) const override { return descendantsOfNode[n]; }
167 
168  List<node> getChildrenOfNode(node n) const override { return childrenOfNode[n]; }
169 
170  adjEntry getAdjToParent(node n) const override { return edgeToParent[n]; }
171 
172 #ifdef OGDF_HEAVY_DEBUG
173  // this is very expensive
174  void assertTreeConsistency() const {
175  NodeArray<int> marked;
176  marked.init(*pGraph);
177  for (node no : pGraph->nodes) {
178  marked[no] = no->index();
179  }
180 
181  for (edge e : pGraph->edges) {
182  if (isInTree(e)) {
183  node s = e->source();
184  node t = e->target();
185  OGDF_ASSERT(marked[s] != marked[t]);
186  int newIdx = marked[s] < marked[t] ? marked[s] : marked[t];
187  int otherIdx = marked[s] < marked[t] ? marked[t] : marked[s];
188 
189  for (node no : pGraph->nodes) {
190  if (marked[no] == otherIdx) {
191  marked[no] = newIdx;
192  }
193  }
194  }
195  }
196 
197  // afterwards, assert that all nodes are in fact marked
198  int lowest = marked[pGraph->firstNode()];
199  for (edge e : pGraph->edges) {
200  if (!isInTree(e)) {
201  OGDF_ASSERT(marked[e->source()] == lowest && marked[e->target()] == lowest);
202  }
203  }
204  }
205 #endif
206 
207 
208 protected:
210  node root; // root node
211 
212  NodeArray<int> levelOfNode; // holds for each node on which level it is
213  NodeArray<node> parentOfNode; // holds for each node which node is his parent in the tree
214  NodeArray<List<node>> childrenOfNode; // holds for each node a list of children in the tree
215  NodeArray<adjEntry> edgeToParent; // holds for each node the edge which connects it to its parent
216  NodeArray<int> descendantsOfNode; // holds for each node how many descendants it has in the tree
218  EdgeArray<bool> inTree; // hold for each edge whether it is in the BFS tree
219 };
220 
225 public:
234  BFSTreeClassical(GraphCopy& G, node rootNode, unsigned int heightMaxIterations,
235  bool findLevelsSimple = false);
236 
238 
245  void construct(node rootNode, unsigned int numIterations);
246 
250  void reconstruct();
251 
257  void createNewRoot(bool useTriBFS = false);
258 
265  int getSizeOfLevel(int level) const;
266 
273  List<node> getLevel(int level) const;
274 
282  List<node> getNodesFromTo(int start, int end) const;
283 
290  List<node> getNodesFrom(int start) const;
291 
300  void restructure(List<node>& separator, List<node>& second, bool useTriBFS = false);
301 
308  void removeSeparatorLevels(List<node>& separator, List<node>& second);
309 
316  bool isVisited(node n) const { return mark[n]; }
317 
318  int getSeparatorLevel() const { return currentLevel; }
319 
320  int get_t0() const { return t0; }
321 
322  int get_t1() const { return t1; }
323 
324  int get_t2() const { return t2; }
325 
326 protected:
331  void findLevels();
332 
336  void findLevelsSimple();
337 
338 
339 private:
340  List<List<node>> levels; // contains all levels, each as a list of nodes
341 
342  unsigned int heightMaxIterations;
343  bool simple; // stupid workaround for being able to change generation of level t0 and t2
344 
345  // construction
346  int currentLevel = 0;
347  bool belowMiddle = true;
348  double m_ratio;
349 
350  // separator levels
351  int t0;
352  int t1;
353  int t2;
354  int k; // number of nodes in levels 0 through t1
355 
356  void visit(node v, node parent, adjEntry adj, SListPure<node>& bfs);
357 };
358 
363 public:
365 
366  virtual ~Postprocessor() {};
367 
377  virtual bool apply(const Graph& G, List<node>& separator, List<node>& first,
378  List<node>& second) = 0;
379 
384  virtual std::string getName() const = 0;
385 };
386 
391 public:
398  NodeExpulsor(bool balance = true) : keepBalance {balance} { }
399 
400  bool apply(const Graph& G, List<node>& separator, List<node>& first, List<node>& second) override;
401 
402  std::string getName() const override { return "NE"; }
403 
404 private:
406 };
407 
414 public:
415  bool apply(const Graph& G, List<node>& separator, List<node>& first, List<node>& second) override;
416 
417  std::string getName() const override { return "DMD"; }
418 
419 private:
420  NodeArray<short> assignments; // assigns numbers to nodes: 0 = n is in separator, 1 = n is in shorter list, 2 = n is in longer list
421 
422  List<node> bipartSep; // clones of separator nodes in the bipartite graph
423  List<node> bipartB; // clones of B-nodes in the bipartite graph
424 
425  // arrays from original graph G
426  NodeArray<bool> isInS; // contains whether a node is in the separator or not
427  NodeArray<node> clone; // maps from G to bipartite graph
428 
429  // arrays from bipartite graph
430  NodeArray<node> unclone; // maps from bipartite graph to G
431  EdgeArray<bool> flow; // contains whether an edge is in the matching or not
432 
433  // Dulmage Mendelsohn Decomposition
437 
441 
445  void reset();
446 
456  void setupAssignments(const Graph& G, const List<node>& separator, const List<node>& first,
457  const List<node>& second);
458 
465  void bipartiteGraph(Graph& graph, const List<node>& separator);
466 
475  void translateAssignments(const Graph& G, List<node>& separator, List<node>& first,
476  List<node>& second) const;
477 
483  void calculateRemainders(const Graph& graph);
484 
494  void chooseBalancedDecomposition(const Graph& G, List<node>& separator, List<node>& first,
495  List<node>& second);
496 
507  bool alternatingBFS(const Graph& G, const List<node>& startNodes, List<node>& reachableSep,
508  List<node>& reachableB);
509 
519  void decompose(const Graph& graph, const List<node>& bipart, List<node>& reachableSep,
520  List<node>& reachableB);
521 };
522 
527 public:
534  Cycle(BFSTree* tree, edge startEdge);
535 
536  Cycle& operator=(Cycle&& other) {
537  tree = other.tree;
538  nodes = std::move(other.nodes);
539  edges = std::move(other.edges);
540  isOnCycle = std::move(other.isOnCycle);
541  isEdgeOnCycle = std::move(other.isEdgeOnCycle);
542  cycleRoot = other.cycleRoot;
543  costClock = other.costClock;
544  costCounter = other.costCounter;
545  isClockwise = other.isClockwise;
546 
547  other.tree = nullptr;
548  other.cycleRoot = nullptr;
549 
550  return *this;
551  }
552 
553  Cycle(Cycle&& other)
554  : tree {other.tree}
555  , nodes(std::move(other.nodes))
556  , edges(std::move(other.edges))
557  , isOnCycle(std::move(other.isOnCycle))
558  , isEdgeOnCycle(std::move(other.isEdgeOnCycle))
559  , cycleRoot {other.cycleRoot}
560  , costClock {other.costClock}
561  , costCounter {other.costCounter}
562  , isClockwise {other.isClockwise} {
563  other.tree = nullptr;
564  other.cycleRoot = nullptr;
565  }
566 
572  int getSize() const { return nodes.size(); }
573 
580  bool getClockwise() const { return isClockwise; }
581 
587  const List<node>& getNodes() const { return nodes; }
588 
594  const List<adjEntry>& getEdges() const { return edges; }
595 
601  const node& getRoot() const { return cycleRoot; }
602 
609  int getInsideCost() const;
610 
617  int getOutsideCost() const;
618 
625  Cycle expandCycle();
626 
630  void print() const;
631 
643  void fillLists(List<node>& separator, List<node>& first, List<node>& second,
644  bool useRoot = false);
645 
646 private:
650  class Iterator {
651  private:
652  const Cycle* cycle;
654  const bool isClockwise;
655 
662  adjEntry next(adjEntry current) const {
663  adjEntry next;
664 
665  if (isClockwise) {
666  if (cycle->isEdgeOnCycle[m_current->theEdge()]) {
667  next = current->twin()->cyclicSucc();
668  } else {
669  next = current->cyclicSucc();
670  }
671  } else {
672  if (cycle->isEdgeOnCycle[m_current->theEdge()]) {
673  next = current->twin()->cyclicPred();
674  } else {
675  next = current->cyclicPred();
676  }
677  }
678  if (next->theEdge() == cycle->getCurrentExpandEdge()->theEdge()) {
679  return nullptr;
680  }
681  return next;
682  }
683 
684  public:
691  Iterator(const Cycle* cyc, bool clockwise)
692  : cycle {cyc}, m_current {cyc->getCurrentExpandEdge()}, isClockwise {clockwise} {
693  ++(*this);
694  }
695 
701  Iterator(const Cycle* cyc) : cycle(cyc), m_current(nullptr), isClockwise {false} { }
702 
707  bool isOutEdge() {
708  return m_current->theNode() == cycle->cycleRoot
709  && m_current == cycle->tree->getAdjToParent(cycle->cycleRoot);
710  }
711 
712  adjEntry operator*() const { return m_current; }
713 
715  m_current = next(m_current);
716  while (m_current != nullptr
717  && cycle->isEdgeOnCycle[m_current->theEdge()]) { //m_current == cycle->sep.edgeToParent[m_current->theNode()]) {
718  m_current = next(m_current);
719  }
720  return *this;
721  }
722 
724  Iterator tmp = *this;
725  ++(*this);
726  return tmp;
727  }
728 
729  friend bool operator==(const Iterator& a, const Iterator& b) {
730  return a.m_current == b.m_current;
731  };
732 
733  friend bool operator!=(const Iterator& a, const Iterator& b) {
734  return a.m_current != b.m_current;
735  };
736  };
737 
738  BFSTree* tree; // the BFS-Tree with which this cycle is associated
739 
740  List<node> nodes; // nodes on the cycle
741  List<adjEntry> edges; // edges on the cycle
742  NodeArray<bool> isOnCycle; // holds for each node whether it is on the cycle or not
743  EdgeArray<bool> isEdgeOnCycle; // holds for each edge whether it is on the cycle or not
744 
745  node cycleRoot; // root node of the cycle, i.e. node in which its two arms meet
746 
747  int costClock {0}; // cost of clockwise nodes
748  int costCounter {0}; // cost of counter-clockwise nodes
750 
760  Cycle(BFSTree* tree, List<node>& nodeList, List<adjEntry>& edgeList, node root, bool clockwise);
761 
768  Cycle(BFSTree* tree, bool clockwise);
769 
777  void init(List<node>& nodeList, List<adjEntry>& edgeList, node root);
778 
780  Iterator begin() const { return Iterator(this, isClockwise); }
781 
782  Iterator end() const { return Iterator(this); }
783 
787  void popBackNode();
788 
789  void popBackEdge();
790 
791  void popFrontNode();
792 
793  void popFrontEdge();
794 
795  void pushFrontEdge(adjEntry adj);
796 
802  adjEntry getCurrentExpandEdge() const;
803 
814  void expandWithTreeEdge(node y, node v, node w, adjEntry vy, adjEntry yw);
815 
828  Cycle expandWithoutTreeEdges(node y, const node v, const node w, const adjEntry vy,
829  const adjEntry yw);
830 
842  std::pair<node, node> findPathToCycle(node& y, List<node>& pathNodes,
843  List<adjEntry>& pathAdjEntries) const;
844 
859  bool findAlphaCycle(Cycle& cyc, const List<node>& pathNodes,
860  const List<adjEntry>& pathAdjEntries, const node z, const node propRoot,
861  const adjEntry yw, List<node>& oldNodes, List<adjEntry>& oldEdges) const;
862 
877  void findBetaCycle(Cycle& cyc, const List<node>& pathNodes, const List<adjEntry>& pathAdjEntries,
878  const node z, const node propRoot, const adjEntry vy, List<node>& oldNodes,
879  List<adjEntry>& oldEdges, bool foundRootOnAlpha) const;
880 
888  void increaseCost(adjEntry adj, bool clockwise);
889 
899  void collectChildrenOfNode(const node no, NodeArray<bool>& marked, List<node>& list,
900  bool useRoot = false) const;
901 
905  void computeCosts();
906 };
907 
908 } // namespace planar_separators
909 
910 using namespace planar_separators;
911 
913 
917 public:
919 
921 
927  void addPostProcessor(Postprocessor& post) { postProcessors.push_back(&post); }
928 
932  void clearPostProcessors() { postProcessors.clear(); }
933 
934  void setStartIndex(int index) { startNodeIndex = index; }
935 
951  virtual bool separate(const Graph& G, List<node>& separator, List<node>& first,
952  List<node>& second, bool checkPreconditions = true) final {
953  if (setup(G, separator, first, second, checkPreconditions)) {
954  return true;
955  }
956 
957  reset(); // reset everything to ensure the module can be reused
958 
959  bool result = doSeparate(G, separator, first, second); // call core algorithm
960 
961  if (result) {
962  cleanup(G, separator, first, second);
963 
964  postProcess(G, separator, first, second);
965  }
966 
967  return result;
968  }
969 
979  virtual bool separate(const Graph& G, NodeArray<short>& assignments,
980  bool checkPreconditions = true) final {
981  OGDF_ASSERT(assignments.graphOf() == &G);
982 
983  List<node> separator;
984  List<node> first;
985  List<node> second;
986 
987  bool result = separate(G, separator, first, second, checkPreconditions);
988 
989  if (!result) {
990  return false;
991  }
992 
993  for (node n : separator) {
994  assignments[n] = 0;
995  }
996  for (node n : first) {
997  assignments[n] = 1;
998  }
999  for (node n : second) {
1000  assignments[n] = 2;
1001  }
1002  return true;
1003  }
1004 
1011  virtual std::string getName() const {
1012  std::string name = getSpecificName();
1013  for (const auto& post : postProcessors) {
1014  name += "_" + post->getName();
1015  }
1016  return name;
1017  }
1018 
1024  std::string getExitPoint() const { return exitPoint; }
1025 
1034  virtual double getMaxSeparatorSize(int n) const = 0;
1035 
1036 protected:
1037  std::vector<Postprocessor*> postProcessors;
1038 
1039  std::shared_ptr<GraphCopy> graph;
1040 
1041  int startNodeIndex = -1;
1042 
1043  // the algorithms can return at different points - this variable stores where that happened, for analysis only
1044  std::string exitPoint;
1045 
1052  node getStartNode(const Graph& G) const {
1053  if (startNodeIndex == -1) {
1054  return G.chooseNode();
1055  } else {
1056  return G.chooseNode([&](node n) { return (n->index() == startNodeIndex); });
1057  }
1058  }
1059 
1070  virtual bool doSeparate(const Graph& G, List<node>& separator, List<node>& first,
1071  List<node>& second) = 0;
1072 
1084  bool setup(const Graph& G, List<node>& separator, List<node>& first, List<node>& second,
1085  bool checkPreconditions = true) {
1086  exitPoint = "graph_trivial";
1087  if (G.empty()) {
1088  return true; // an empty graph is separated without us doing anything
1089  }
1090 
1091  OGDF_ASSERT(isPlanar(G));
1092 
1093  graph = std::make_shared<GraphCopy>(G);
1094 
1095  // call separateComponents to check if we even need to do anything, return success if not
1096  if (separateComponents(*graph, separator, first, second)) {
1097  return true;
1098  }
1099 
1100  // even checking these conditions is expensive, so if you know that they all hold, you can skip this
1101  if (checkPreconditions) {
1102  if (!graph->representsCombEmbedding()) {
1103  planarEmbedPlanarGraph(*graph);
1104  }
1105  if (!isSimpleUndirected(*graph)) {
1106  makeSimpleUndirected(*graph);
1107  }
1108  }
1109 
1110  OGDF_ASSERT(graph->representsCombEmbedding());
1111  OGDF_ASSERT(isConnected(*graph));
1113 
1114  return false;
1115  }
1116 
1127  bool cleanup(const Graph& G, List<node>& separator, List<node>& first, List<node>& second) {
1128  if (first.empty() && second.empty()) {
1129  for (int i = 0; i < G.numberOfNodes() / 2.0; i++) {
1130  first.pushBack(separator.popFrontRet());
1131  }
1132  return true;
1133  }
1134  return false;
1135  }
1136 
1148  bool separateComponents(GraphCopy& G, List<node>& separator, List<node>& first,
1149  List<node>& second, bool skip = false) const;
1150 
1160  bool postProcess(const Graph& G, List<node>& separator, List<node>& first, List<node>& second) {
1161  for (Postprocessor* post : postProcessors) {
1162  post->apply(G, separator, first, second);
1163  }
1164  return true;
1165  }
1166 
1173  virtual std::string getSpecificName() const = 0;
1174 
1178  virtual void reset() {};
1179 
1180 private:
1190  int connectedComponents(const Graph& G, NodeArray<int>& component,
1191  std::map<int, int>& compSizes) const;
1192 };
1193 
1194 
1195 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::planar_separators::Cycle::getCurrentExpandEdge
adjEntry getCurrentExpandEdge() const
Gets the current non-tree edge on the cycle, which is the one that will be used to expand the cycle f...
ogdf::PlanarSeparatorModule::PlanarSeparatorModule
PlanarSeparatorModule()
Definition: PlanarSeparatorModule.h:918
ogdf::PlanarSeparatorModule::postProcess
bool postProcess(const Graph &G, List< node > &separator, List< node > &first, List< node > &second)
Apply all postprocessors.
Definition: PlanarSeparatorModule.h:1160
ogdf::planar_separators::DMDecomposer::BR
List< node > BR
Definition: PlanarSeparatorModule.h:440
ogdf::planar_separators::Cycle::Iterator::next
adjEntry next(adjEntry current) const
Yields the next adjEntry, given the current one (internal use only).
Definition: PlanarSeparatorModule.h:662
Graph.h
Includes declaration of graph class.
ogdf::planar_separators::Cycle::Iterator::operator!=
friend bool operator!=(const Iterator &a, const Iterator &b)
Definition: PlanarSeparatorModule.h:733
ogdf::planar_separators::Cycle::nodes
List< node > nodes
Definition: PlanarSeparatorModule.h:740
ogdf::connectedComponents
int connectedComponents(const Graph &G, NodeArray< int > &component, List< node > *isolated=nullptr, ArrayBuffer< node > *reprs=nullptr)
Computes the connected components of G and optionally generates a list of isolated nodes.
ogdf::internal::GraphRegisteredArray::graphOf
Graph * graphOf() const
Returns a pointer to the associated graph.
Definition: Graph_d.h:658
ogdf::planar_separators::ArrayBFSTree::levelOfNode
NodeArray< int > levelOfNode
Definition: PlanarSeparatorModule.h:212
ogdf::planar_separators::Cycle::getNodes
const List< node > & getNodes() const
Gets the nodes on the cycle.
Definition: PlanarSeparatorModule.h:587
ogdf::planar_separators::ArrayBFSTree::getAdjToParent
adjEntry getAdjToParent(node n) const override
Returns the adjEntry that leads up to the parent of n.
Definition: PlanarSeparatorModule.h:170
ogdf::planar_separators::DMDecomposer::SI
List< node > SI
Definition: PlanarSeparatorModule.h:434
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::planar_separators::Cycle::edges
List< adjEntry > edges
Definition: PlanarSeparatorModule.h:741
ogdf::planar_separators::ArrayBFSTree::getChildrenOfNode
List< node > getChildrenOfNode(node n) const override
Returns all (immediate) children of a node.
Definition: PlanarSeparatorModule.h:168
ogdf::planar_separators::NodeExpulsor::keepBalance
bool keepBalance
Definition: PlanarSeparatorModule.h:405
ogdf::planar_separators::DMDecomposer::BI
List< node > BI
Definition: PlanarSeparatorModule.h:438
ogdf::planar_separators::Cycle::end
Iterator end() const
Definition: PlanarSeparatorModule.h:782
ogdf::AdjElement::theNode
node theNode() const
Returns the node whose adjacency list contains this element.
Definition: Graph_d.h:159
ogdf::planar_separators::ArrayBFSTree::getRoot
node getRoot() const override
Gets the current root node of the tree.
Definition: PlanarSeparatorModule.h:153
ogdf::planar_separators::BFSTree::getAdjToParent
virtual adjEntry getAdjToParent(node n) const =0
Returns the adjEntry that leads up to the parent of n.
ogdf::planar_separators::Cycle::Iterator::operator*
adjEntry operator*() const
Definition: PlanarSeparatorModule.h:712
ogdf::NodeElement::index
int index() const
Returns the (unique) node index.
Definition: Graph_d.h:267
ogdf::AdjElement::cyclicPred
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
Definition: Graph_d.h:351
ogdf::planar_separators::DMDecomposer::flow
EdgeArray< bool > flow
Definition: PlanarSeparatorModule.h:431
ogdf::planar_separators::ArrayBFSTree::getLevelOfNode
int getLevelOfNode(node n) const override
Returns the level (=depth in the tree) for a node.
Definition: PlanarSeparatorModule.h:162
ogdf::List::popFrontRet
E popFrontRet()
Removes the first element from the list and returns it.
Definition: List.h:1581
extended_graph_alg.h
Declaration of extended graph algorithms.
ogdf::PlanarSeparatorModule::separate
virtual bool separate(const Graph &G, NodeArray< short > &assignments, bool checkPreconditions=true) final
Separates a planar graph.
Definition: PlanarSeparatorModule.h:979
ogdf::planar_separators::DMDecomposer::bipartSep
List< node > bipartSep
Definition: PlanarSeparatorModule.h:422
backward::Color::reset
@ reset
Definition: backward.hpp:1719
ogdf::PlanarSeparatorModule::postProcessors
std::vector< Postprocessor * > postProcessors
Definition: PlanarSeparatorModule.h:1037
ogdf::planar_separators::ArrayBFSTree
Abstract BFSTree that is realized via NodeArrays.
Definition: PlanarSeparatorModule.h:123
ogdf::planar_separators::Cycle::Iterator::Iterator
Iterator(const Cycle *cyc)
Constructor.
Definition: PlanarSeparatorModule.h:701
ogdf::planar_separators::Cycle::isClockwise
bool isClockwise
Definition: PlanarSeparatorModule.h:749
ogdf::planar_separators::ArrayBFSTree::parentOfNode
NodeArray< node > parentOfNode
Definition: PlanarSeparatorModule.h:213
ogdf::GraphCopy
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:384
ogdf::PlanarSeparatorModule::getName
virtual std::string getName() const
Returns the full name of this algorithm.
Definition: PlanarSeparatorModule.h:1011
ogdf::planar_separators::Cycle::Iterator::isOutEdge
bool isOutEdge()
Checks whether the current adjEntry is the one that leads up to the root.
Definition: PlanarSeparatorModule.h:707
ogdf::PlanarSeparatorModule::setStartIndex
void setStartIndex(int index)
Definition: PlanarSeparatorModule.h:934
ogdf::planar_separators::Cycle::cycleRoot
node cycleRoot
Definition: PlanarSeparatorModule.h:745
ogdf::isPlanar
bool isPlanar(const Graph &G)
Returns true, if G is planar, false otherwise.
Definition: extended_graph_alg.h:274
ogdf::makeSimpleUndirected
void makeSimpleUndirected(Graph &G)
Removes all self-loops and all but one edge of each bundle of undirected parallel edges.
Definition: simple_graph_alg.h:425
ogdf::planar_separators::Postprocessor
Abstract description of postprocessors.
Definition: PlanarSeparatorModule.h:362
ogdf::planar_separators::Cycle::Iterator::m_current
adjEntry m_current
Definition: PlanarSeparatorModule.h:653
ogdf::planar_separators::ArrayBFSTree::getDescendantsOfNode
int getDescendantsOfNode(node n) const override
Returns the total number of children, grandchildren etc.
Definition: PlanarSeparatorModule.h:166
ogdf::isConnected
bool isConnected(const Graph &G)
Returns true iff G is connected.
ogdf::planar_separators::BFSTreeClassical::heightMaxIterations
unsigned int heightMaxIterations
Definition: PlanarSeparatorModule.h:342
ogdf::planar_separators::BFSTreeClassical::isVisited
bool isVisited(node n) const
Checks whether a node is visited by BFS.
Definition: PlanarSeparatorModule.h:316
ogdf::planar_separators::Cycle::Iterator::operator==
friend bool operator==(const Iterator &a, const Iterator &b)
Definition: PlanarSeparatorModule.h:729
ogdf::planar_separators::ArrayBFSTree::getGraph
GraphCopy * getGraph() const override
Allows access to a copy of the graph.
Definition: PlanarSeparatorModule.h:151
ogdf::AdjElement::twin
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
Definition: Graph_d.h:165
ogdf::PlanarSeparatorModule::exitPoint
std::string exitPoint
Definition: PlanarSeparatorModule.h:1044
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::planar_separators::Cycle::Iterator::operator++
Iterator operator++(int)
Definition: PlanarSeparatorModule.h:723
ogdf::planar_separators::Cycle::begin
Iterator begin() const
Iterators for clockwise iteration over edges on the "inside", starting and ending at currentExpandEdg...
Definition: PlanarSeparatorModule.h:780
ogdf::planar_separators::DMDecomposer::getName
std::string getName() const override
Returns the human-readable identifier of this postprocessor.
Definition: PlanarSeparatorModule.h:417
ogdf::planar_separators::DMDecomposer::bipartB
List< node > bipartB
Definition: PlanarSeparatorModule.h:423
ogdf::planar_separators::Cycle::tree
BFSTree * tree
Definition: PlanarSeparatorModule.h:738
ogdf::PlanarSeparatorModule::reset
virtual void reset()
Reset everything to enable reuse of the module.
Definition: PlanarSeparatorModule.h:1178
ogdf::edge
EdgeElement * edge
The type of edges.
Definition: Graph_d.h:67
ogdf::planar_separators::BFSTreeClassical::get_t2
int get_t2() const
Definition: PlanarSeparatorModule.h:324
ogdf::AdjElement::theEdge
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:153
ogdf::planar_separators::DMDecomposer::SX
List< node > SX
Definition: PlanarSeparatorModule.h:435
ogdf::planar_separators::Cycle::isEdgeOnCycle
EdgeArray< bool > isEdgeOnCycle
Definition: PlanarSeparatorModule.h:743
ogdf::planar_separators::Cycle::isOnCycle
NodeArray< bool > isOnCycle
Definition: PlanarSeparatorModule.h:742
ogdf::planar_separators::BFSTreeClassical::levels
List< List< node > > levels
Definition: PlanarSeparatorModule.h:340
ogdf::planar_separators::ArrayBFSTree::pGraph
GraphCopy * pGraph
Definition: PlanarSeparatorModule.h:209
ogdf::planar_separators::Cycle::getSize
int getSize() const
Returns the size of the cycle = the number of nodes on the cycle.
Definition: PlanarSeparatorModule.h:572
ogdf::planar_separators::BFSTreeClassical::get_t0
int get_t0() const
Definition: PlanarSeparatorModule.h:320
ogdf::PlanarSeparatorModule
Abstract description of all planar separator algorithms.
Definition: PlanarSeparatorModule.h:916
ogdf::planar_separators::DMDecomposer::assignments
NodeArray< short > assignments
Definition: PlanarSeparatorModule.h:420
ogdf::planar_separators::DMDecomposer::isInS
NodeArray< bool > isInS
Definition: PlanarSeparatorModule.h:426
backward::details::move
const T & move(const T &v)
Definition: backward.hpp:243
ogdf::planar_separators::ArrayBFSTree::getParentOfNode
node getParentOfNode(node n) const override
Returns the node that is the parent of n in the tree.
Definition: PlanarSeparatorModule.h:164
ogdf::planar_separators::BFSTreeClassical::simple
bool simple
Definition: PlanarSeparatorModule.h:343
ogdf::planar_separators::ArrayBFSTree::root
node root
Definition: PlanarSeparatorModule.h:210
ogdf::planar_separators::Cycle::Iterator
Special iterator to walk over the inward-pointing edges of the cycle.
Definition: PlanarSeparatorModule.h:650
ogdf::planar_separators::BFSTreeClassical::getSeparatorLevel
int getSeparatorLevel() const
Definition: PlanarSeparatorModule.h:318
ogdf::planar_separators::Cycle::Iterator::cycle
const Cycle * cycle
Definition: PlanarSeparatorModule.h:652
ogdf::planar_separators::BFSTree
Abstract description of a Breadth First Search tree.
Definition: PlanarSeparatorModule.h:49
ogdf::SListPure
Singly linked lists.
Definition: SList.h:39
ogdf::PlanarSeparatorModule::getExitPoint
std::string getExitPoint() const
Returns the exitPoint, i.e.
Definition: PlanarSeparatorModule.h:1024
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:391
ogdf::planar_separators::ArrayBFSTree::descendantsOfNode
NodeArray< int > descendantsOfNode
Definition: PlanarSeparatorModule.h:216
GraphCopy.h
Declaration of graph copy classes.
ogdf::planar_separators::BFSTreeClassical::m_ratio
double m_ratio
Definition: PlanarSeparatorModule.h:348
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: List.h:42
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::planar_separators::BFSTreeClassical::k
int k
Definition: PlanarSeparatorModule.h:354
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::planar_separators::ArrayBFSTree::inTree
EdgeArray< bool > inTree
Definition: PlanarSeparatorModule.h:218
ogdf::planar_separators::DMDecomposer::BX
List< node > BX
Definition: PlanarSeparatorModule.h:439
ogdf::isSimpleUndirected
bool isSimpleUndirected(const Graph &G)
Returns true iff G contains neither self-loops nor undirected parallel edges.
Definition: simple_graph_alg.h:415
ogdf::planar_separators::NodeExpulsor
NodeExpulsor: Remove all nodes that are not connected to both halves of the separation.
Definition: PlanarSeparatorModule.h:390
ogdf::planar_separators::Postprocessor::Postprocessor
Postprocessor()
Definition: PlanarSeparatorModule.h:364
ogdf::planar_separators::ArrayBFSTree::getGraphSize
int getGraphSize() const override
Gets the number of nodes of the graph.
Definition: PlanarSeparatorModule.h:155
ogdf::planar_separators::DMDecomposer
Dulmage-Mendelsohn-Decomposition.
Definition: PlanarSeparatorModule.h:413
ogdf::planar_separators::Cycle::Iterator::isClockwise
const bool isClockwise
Definition: PlanarSeparatorModule.h:654
ogdf::PlanarSeparatorModule::cleanup
bool cleanup(const Graph &G, List< node > &separator, List< node > &first, List< node > &second)
Performs built-in post-processing: For small instances, it can happen that all nodes are assigned to ...
Definition: PlanarSeparatorModule.h:1127
ogdf::AdjElement::cyclicSucc
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Definition: Graph_d.h:347
ogdf::EdgeStandardType::tree
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
ogdf::planar_separators::Postprocessor::~Postprocessor
virtual ~Postprocessor()
Definition: PlanarSeparatorModule.h:366
ogdf::planar_separators::Cycle::Cycle
Cycle(Cycle &&other)
Definition: PlanarSeparatorModule.h:553
ogdf::planar_separators::DMDecomposer::unclone
NodeArray< node > unclone
Definition: PlanarSeparatorModule.h:430
ogdf::planar_separators::Cycle::Iterator::Iterator
Iterator(const Cycle *cyc, bool clockwise)
Constructor.
Definition: PlanarSeparatorModule.h:691
ogdf::graphics::init
void init()
Definition: graphics.h:446
ogdf::planar_separators::ArrayBFSTree::ArrayBFSTree
ArrayBFSTree(GraphCopy &G, node rootNode)
Constructor.
Definition: PlanarSeparatorModule.h:131
ogdf::planar_separators::BFSTreeClassical::~BFSTreeClassical
~BFSTreeClassical()
Definition: PlanarSeparatorModule.h:237
ogdf::PlanarSeparatorModule::setup
bool setup(const Graph &G, List< node > &separator, List< node > &first, List< node > &second, bool checkPreconditions=true)
Performs some initial setup to ensure that all preconditions hold and takes trivial steps to separate...
Definition: PlanarSeparatorModule.h:1084
ogdf::planar_separators::BFSTreeClassical::t1
int t1
Definition: PlanarSeparatorModule.h:352
ogdf::planar_separators::Cycle::getClockwise
bool getClockwise() const
Checks if the cycle is clockwise, i.e.
Definition: PlanarSeparatorModule.h:580
ogdf::PlanarSeparatorModule::graph
std::shared_ptr< GraphCopy > graph
Definition: PlanarSeparatorModule.h:1039
ogdf::end
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::planar_separators::ArrayBFSTree::init
void init()
Initializes all internal arrays.
Definition: PlanarSeparatorModule.h:136
ogdf::planar_separators::Cycle
Auxiliary data structure to represent Cycles in planar graphs.
Definition: PlanarSeparatorModule.h:526
ogdf::planar_separators::ArrayBFSTree::mark
NodeArray< bool > mark
Definition: PlanarSeparatorModule.h:217
ogdf::planar_separators::Cycle::operator=
Cycle & operator=(Cycle &&other)
Definition: PlanarSeparatorModule.h:536
ogdf::print
void print(std::ostream &os, const Array< E, INDEX > &a, char delim=' ')
Prints array a to output stream os using delimiter delim.
Definition: Array.h:967
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::PlanarSeparatorModule::getStartNode
node getStartNode(const Graph &G) const
Selects the starting node for the BFS.
Definition: PlanarSeparatorModule.h:1052
ogdf::RegisteredArray< GraphRegistry< Key >, Value, WithDefault, Graph >::init
void init(const Graph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
Definition: RegisteredArray.h:849
ogdf::planar_separators::ArrayBFSTree::edgeToParent
NodeArray< adjEntry > edgeToParent
Definition: PlanarSeparatorModule.h:215
ogdf::planar_separators::BFSTreeClassical
BFS tree used by both classical algorithms (LT and Dual).
Definition: PlanarSeparatorModule.h:224
ogdf::planar_separators::NodeExpulsor::NodeExpulsor
NodeExpulsor(bool balance=true)
Constructor.
Definition: PlanarSeparatorModule.h:398
ogdf::planar_separators::Cycle::getEdges
const List< adjEntry > & getEdges() const
Gets the adjEntries on the cycle.
Definition: PlanarSeparatorModule.h:594
ogdf::PlanarSeparatorModule::clearPostProcessors
void clearPostProcessors()
Deletes all appended postprocessors from this separator.
Definition: PlanarSeparatorModule.h:932
ogdf::planar_separators::NodeExpulsor::getName
std::string getName() const override
Returns the human-readable identifier of this postprocessor.
Definition: PlanarSeparatorModule.h:402
ogdf::planarEmbedPlanarGraph
bool planarEmbedPlanarGraph(Graph &G)
Constructs a planar embedding of G. It assumes that G is planar!
Definition: extended_graph_alg.h:343
ogdf::planar_separators::DMDecomposer::SR
List< node > SR
Definition: PlanarSeparatorModule.h:436
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:394
ogdf::planar_separators::BFSTreeClassical::t2
int t2
Definition: PlanarSeparatorModule.h:353
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::planar_separators::DMDecomposer::clone
NodeArray< node > clone
Definition: PlanarSeparatorModule.h:427
ogdf::planar_separators::BFSTreeClassical::get_t1
int get_t1() const
Definition: PlanarSeparatorModule.h:322
ogdf::PlanarSeparatorModule::separate
virtual bool separate(const Graph &G, List< node > &separator, List< node > &first, List< node > &second, bool checkPreconditions=true) final
Separates a planar graph.
Definition: PlanarSeparatorModule.h:951
ogdf::planar_separators::Cycle::Iterator::operator++
Iterator & operator++()
Definition: PlanarSeparatorModule.h:714
simple_graph_alg.h
Declaration of simple graph algorithms.
ogdf::planar_separators::BFSTreeClassical::t0
int t0
Definition: PlanarSeparatorModule.h:351
ogdf::planar_separators::ArrayBFSTree::isInTree
bool isInTree(edge e) const override
Checks if an edge is a tree-edge.
Definition: PlanarSeparatorModule.h:160
ogdf::PlanarSeparatorModule::~PlanarSeparatorModule
virtual ~PlanarSeparatorModule()
Definition: PlanarSeparatorModule.h:920
ogdf::planar_separators::Cycle::getRoot
const node & getRoot() const
Gives access to the root node of the cycle.
Definition: PlanarSeparatorModule.h:601
ogdf::List::pushBack
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: List.h:1537
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709
ogdf::PlanarSeparatorModule::addPostProcessor
void addPostProcessor(Postprocessor &post)
Adds a postprocessor to this separator, which will always be applied.
Definition: PlanarSeparatorModule.h:927
ogdf::planar_separators::ArrayBFSTree::childrenOfNode
NodeArray< List< node > > childrenOfNode
Definition: PlanarSeparatorModule.h:214