Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
CoffmanGrahamRanking.h
Go to the documentation of this file.
1
33#pragma once
34
35#include <ogdf/basic/Graph.h>
36#include <ogdf/basic/basic.h>
39
40#include <memory>
41
42namespace ogdf {
43template<class E1, class E2>
44class Tuple2;
45template<class E>
46class List;
47
49
58public:
61
62
69 virtual void call(const Graph& G, NodeArray<int>& rank) override;
70
77 void setSubgraph(AcyclicSubgraphModule* pSubgraph) { m_subgraph.reset(pSubgraph); }
78
80
82 int width() const { return m_w; }
83
85 void width(int w) { m_w = w; }
86
87
88private:
89 // CoffmanGraham data structures
90 class _int_set {
91 int* m_array;
94
95 public:
96 _int_set() : m_array(nullptr), m_length(0), m_index(0) { }
97
98 explicit _int_set(int len) : m_array(nullptr), m_length(len), m_index(len) {
99 if (len > 0) {
100 m_array = new int[m_length];
101 }
102 }
103
104 ~_int_set() { delete[] m_array; }
105
106 void init(int len) {
107 delete m_array;
108 if ((m_length = len) == 0) {
109 m_array = nullptr;
110 } else {
111 m_array = new int[m_length];
112 }
113 m_index = len;
114 }
115
116 int length() const { return m_length; }
117
118 int operator[](int i) const { return m_array[i]; }
119
120 void insert(int x) { m_array[--m_index] = x; }
121
122 bool ready() const { return m_index == 0; }
123 };
124
125 // CoffmanGraham members
126 std::unique_ptr<AcyclicSubgraphModule> m_subgraph;
127 int m_w;
129
130 // dfs members
132
133 // CoffmanGraham funktions
134 void insert(node u, List<Tuple2<node, int>>& ready_nodes);
135 void insert(node u, List<node>& ready, const NodeArray<int>& pi);
136
137 // dfs funktions
139 void dfs(node v);
140};
141
142}
Declaration of interface for acyclic subgraph algorithms.
Includes declaration of graph class.
Declaration of interface for ranking algorithms.
Basic declarations, included by all source files.
Base class of algorithms for computing a maximal acyclic subgraph.
The coffman graham ranking algorithm.
CoffmanGrahamRanking()
Creates an instance of coffman graham ranking.
void setSubgraph(AcyclicSubgraphModule *pSubgraph)
Sets the module for the computation of the acyclic subgraph.
void width(int w)
Set for the with.
int width() const
Get for the with.
std::unique_ptr< AcyclicSubgraphModule > m_subgraph
void insert(node u, List< Tuple2< node, int > > &ready_nodes)
void insert(node u, List< node > &ready, const NodeArray< int > &pi)
void removeTransitiveEdges(Graph &G)
virtual void call(const Graph &G, NodeArray< int > &rank) override
Computes a node ranking of G in rank.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
Class for the representation of nodes.
Definition Graph_d.h:241
Interface of algorithms for computing a node ranking.
Tuples of two elements (2-tuples).
Definition tuples.h:49
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
The namespace for all OGDF objects.