|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
53 namespace planar_separators {
72 virtual node getRoot()
const = 0;
78 virtual int getGraphSize()
const = 0;
86 virtual bool isInTree(
edge e)
const = 0;
94 virtual int getLevelOfNode(
node n)
const = 0;
102 virtual node getParentOfNode(
node n)
const = 0;
110 virtual int getDescendantsOfNode(
node n)
const = 0;
147 levelOfNode.init(*pGraph, -1);
148 parentOfNode.init(*pGraph,
nullptr);
149 childrenOfNode.init(*pGraph);
150 edgeToParent.init(*pGraph,
nullptr);
151 descendantsOfNode.init(*pGraph,
153 inTree.init(*pGraph,
false);
154 mark.init(*pGraph,
false);
166 return pGraph->numberOfNodes();
181 #ifdef OGDF_HEAVY_DEBUG
183 void assertTreeConsistency()
const {
185 marked.
init(*pGraph);
186 for (
node no : pGraph->nodes) {
187 marked[no] = no->
index();
190 for (
edge e : pGraph->edges) {
195 int newIdx = marked[s] < marked[t] ? marked[s] : marked[t];
196 int otherIdx = marked[s] < marked[t] ? marked[t] : marked[s];
198 for (
node no : pGraph->nodes) {
199 if (marked[no] == otherIdx) {
207 int lowest = marked[pGraph->firstNode()];
208 for (
edge e : pGraph->edges) {
210 OGDF_ASSERT(marked[e->source()] == lowest && marked[e->target()] == lowest);
244 bool findLevelsSimple =
false);
254 void construct(
node rootNode,
unsigned int numIterations);
266 void createNewRoot(
bool useTriBFS =
false);
274 int getSizeOfLevel(
int level)
const;
345 void findLevelsSimple();
355 int currentLevel = 0;
356 bool belowMiddle =
true;
393 virtual std::string getName()
const = 0;
411 std::string
getName()
const override {
return "NE"; }
426 std::string
getName()
const override {
return "DMD"; }
492 void calculateRemainders(
const Graph& graph);
550 isEdgeOnCycle =
std::move(other.isEdgeOnCycle);
551 cycleRoot = other.cycleRoot;
552 costClock = other.costClock;
553 costCounter = other.costCounter;
554 isClockwise = other.isClockwise;
556 other.tree =
nullptr;
557 other.cycleRoot =
nullptr;
567 , isEdgeOnCycle(
std::move(other.isEdgeOnCycle))
568 , cycleRoot {other.cycleRoot}
569 , costClock {other.costClock}
570 , costCounter {other.costCounter}
571 , isClockwise {other.isClockwise} {
572 other.tree =
nullptr;
573 other.cycleRoot =
nullptr;
618 int getInsideCost()
const;
626 int getOutsideCost()
const;
653 bool useRoot =
false);
701 : cycle {cyc}, m_current {cyc->getCurrentExpandEdge()}, isClockwise {clockwise} {
710 Iterator(
const Cycle* cyc) : cycle(cyc), m_current(nullptr), isClockwise {
false} { }
724 m_current = next(m_current);
725 while (m_current !=
nullptr
727 m_current = next(m_current);
811 adjEntry getCurrentExpandEdge()
const;
851 std::pair<node, node> findPathToCycle(
node& y,
List<node>& pathNodes,
897 void increaseCost(
adjEntry adj,
bool clockwise);
909 bool useRoot =
false)
const;
919 using namespace planar_separators;
961 List<node>& second,
bool checkPreconditions =
true) final {
962 if (setup(G, separator, first, second, checkPreconditions)) {
968 bool result = doSeparate(G, separator, first, second);
971 cleanup(G, separator, first, second);
973 postProcess(G, separator, first, second);
989 bool checkPreconditions =
true) final {
996 bool result = separate(G, separator, first, second, checkPreconditions);
1002 for (
node n : separator) {
1005 for (
node n : first) {
1008 for (
node n : second) {
1021 std::string name = getSpecificName();
1022 for (
const auto& post : postProcessors) {
1023 name +=
"_" + post->getName();
1043 virtual double getMaxSeparatorSize(
int n)
const = 0;
1050 int startNodeIndex = -1;
1062 if (startNodeIndex == -1) {
1063 return G.chooseNode();
1065 return G.chooseNode([&](
node n) {
return (n->
index() == startNodeIndex); });
1094 bool checkPreconditions =
true) {
1095 exitPoint =
"graph_trivial";
1102 graph = std::make_shared<GraphCopy>(G);
1105 if (separateComponents(*graph, separator, first, second)) {
1110 if (checkPreconditions) {
1111 if (!graph->representsCombEmbedding()) {
1137 if (first.empty() && second.empty()) {
1138 for (
int i = 0; i < G.numberOfNodes() / 2.0; i++) {
1158 List<node>& second,
bool skip =
false)
const;
1171 post->apply(G, separator, first, second);
1182 virtual std::string getSpecificName()
const = 0;
1200 std::map<int, int>& compSizes)
const;
The namespace for all OGDF objects.
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...
bool postProcess(const Graph &G, List< node > &separator, List< node > &first, List< node > &second)
Apply all postprocessors.
adjEntry next(adjEntry current) const
Yields the next adjEntry, given the current one (internal use only).
Includes declaration of graph class.
friend bool operator!=(const Iterator &a, const Iterator &b)
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.
Graph * graphOf() const
Returns a pointer to the associated graph.
NodeArray< int > levelOfNode
const List< node > & getNodes() const
Gets the nodes on the cycle.
adjEntry getAdjToParent(node n) const override
Returns the adjEntry that leads up to the parent of n.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
List< node > getChildrenOfNode(node n) const override
Returns all (immediate) children of a node.
node theNode() const
Returns the node whose adjacency list contains this element.
node getRoot() const override
Gets the current root node of the tree.
virtual adjEntry getAdjToParent(node n) const =0
Returns the adjEntry that leads up to the parent of n.
adjEntry operator*() const
int index() const
Returns the (unique) node index.
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
int getLevelOfNode(node n) const override
Returns the level (=depth in the tree) for a node.
E popFrontRet()
Removes the first element from the list and returns it.
Declaration of extended graph algorithms.
virtual bool separate(const Graph &G, NodeArray< short > &assignments, bool checkPreconditions=true) final
Separates a planar graph.
std::vector< Postprocessor * > postProcessors
Abstract BFSTree that is realized via NodeArrays.
Iterator(const Cycle *cyc)
Constructor.
NodeArray< node > parentOfNode
Copies of graphs supporting edge splitting.
virtual std::string getName() const
Returns the full name of this algorithm.
bool isOutEdge()
Checks whether the current adjEntry is the one that leads up to the root.
void setStartIndex(int index)
bool isPlanar(const Graph &G)
Returns true, if G is planar, false otherwise.
void makeSimpleUndirected(Graph &G)
Removes all self-loops and all but one edge of each bundle of undirected parallel edges.
Abstract description of postprocessors.
int getDescendantsOfNode(node n) const override
Returns the total number of children, grandchildren etc.
bool isConnected(const Graph &G)
Returns true iff G is connected.
unsigned int heightMaxIterations
bool isVisited(node n) const
Checks whether a node is visited by BFS.
friend bool operator==(const Iterator &a, const Iterator &b)
GraphCopy * getGraph() const override
Allows access to a copy of the graph.
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
Class for adjacency list elements.
Iterator begin() const
Iterators for clockwise iteration over edges on the "inside", starting and ending at currentExpandEdg...
std::string getName() const override
Returns the human-readable identifier of this postprocessor.
virtual void reset()
Reset everything to enable reuse of the module.
EdgeElement * edge
The type of edges.
edge theEdge() const
Returns the edge associated with this adjacency entry.
EdgeArray< bool > isEdgeOnCycle
NodeArray< bool > isOnCycle
List< List< node > > levels
int getSize() const
Returns the size of the cycle = the number of nodes on the cycle.
Abstract description of all planar separator algorithms.
NodeArray< short > assignments
const T & move(const T &v)
Decralation of GraphElement and GraphList classes.
node getParentOfNode(node n) const override
Returns the node that is the parent of n in the tree.
Special iterator to walk over the inward-pointing edges of the cycle.
int getSeparatorLevel() const
Abstract description of a Breadth First Search tree.
std::string getExitPoint() const
Returns the exitPoint, i.e.
node source() const
Returns the source node of the edge.
NodeArray< int > descendantsOfNode
Declaration of graph copy classes.
Doubly linked lists (maintaining the length of the list).
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.
NodeExpulsor: Remove all nodes that are not connected to both halves of the separation.
int getGraphSize() const override
Gets the number of nodes of the graph.
Dulmage-Mendelsohn-Decomposition.
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 ...
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
NodeArray< node > unclone
Iterator(const Cycle *cyc, bool clockwise)
Constructor.
ArrayBFSTree(GraphCopy &G, node rootNode)
Constructor.
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...
Basic declarations, included by all source files.
bool getClockwise() const
Checks if the cycle is clockwise, i.e.
std::shared_ptr< GraphCopy > graph
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
void init()
Initializes all internal arrays.
Auxiliary data structure to represent Cycles in planar graphs.
Cycle & operator=(Cycle &&other)
void print(std::ostream &os, const Array< E, INDEX > &a, char delim=' ')
Prints array a to output stream os using delimiter delim.
Class for the representation of edges.
node getStartNode(const Graph &G) const
Selects the starting node for the BFS.
Declaration of doubly linked lists and iterators.
void init(const Graph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
NodeArray< adjEntry > edgeToParent
BFS tree used by both classical algorithms (LT and Dual).
NodeExpulsor(bool balance=true)
Constructor.
const List< adjEntry > & getEdges() const
Gets the adjEntries on the cycle.
void clearPostProcessors()
Deletes all appended postprocessors from this separator.
std::string getName() const override
Returns the human-readable identifier of this postprocessor.
bool planarEmbedPlanarGraph(Graph &G)
Constructs a planar embedding of G. It assumes that G is planar!
node target() const
Returns the target node of the edge.
Class for the representation of nodes.
virtual bool separate(const Graph &G, List< node > &separator, List< node > &first, List< node > &second, bool checkPreconditions=true) final
Separates a planar graph.
Declaration of simple graph algorithms.
bool isInTree(edge e) const override
Checks if an edge is a tree-edge.
virtual ~PlanarSeparatorModule()
const node & getRoot() const
Gives access to the root node of the cycle.
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 addPostProcessor(Postprocessor &post)
Adds a postprocessor to this separator, which will always be applied.
NodeArray< List< node > > childrenOfNode