Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
42 namespace ogdf {
43 template<class E1, class E2>
44 class Tuple2;
45 template<class E>
46 class List;
47 
49 
58 public:
61 
62 
68  virtual void call(const Graph& G, NodeArray<int>& rank) override;
70 
76  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 
88 private:
89  // CoffmanGraham data structures
90  class _int_set {
91  int* m_array;
92  int m_length;
93  int m_index;
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
138  void removeTransitiveEdges(Graph& G);
139  void dfs(node v);
140 };
141 
142 }
ogdf::CoffmanGrahamRanking::_int_set::init
void init(int len)
Definition: CoffmanGrahamRanking.h:106
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::CoffmanGrahamRanking::_int_set::m_index
int m_index
Definition: CoffmanGrahamRanking.h:93
Graph.h
Includes declaration of graph class.
ogdf::CoffmanGrahamRanking::_int_set::_int_set
_int_set(int len)
Definition: CoffmanGrahamRanking.h:98
RankingModule.h
Declaration of interface for ranking algorithms.
ogdf::CoffmanGrahamRanking::_int_set::_int_set
_int_set()
Definition: CoffmanGrahamRanking.h:96
ogdf::Tuple2
Tuples of two elements (2-tuples).
Definition: tuples.h:49
ogdf::CoffmanGrahamRanking::width
int width() const
Get for the with.
Definition: CoffmanGrahamRanking.h:82
ogdf::CoffmanGrahamRanking::m_mark
NodeArray< int > m_mark
Definition: CoffmanGrahamRanking.h:131
ogdf::RankingModule
Interface of algorithms for computing a node ranking.
Definition: RankingModule.h:46
ogdf::CoffmanGrahamRanking::width
void width(int w)
Set for the with.
Definition: CoffmanGrahamRanking.h:85
AcyclicSubgraphModule.h
Declaration of interface for acyclic subgraph algorithms.
ogdf::CoffmanGrahamRanking::_int_set::~_int_set
~_int_set()
Definition: CoffmanGrahamRanking.h:104
ogdf::CoffmanGrahamRanking::_int_set::ready
bool ready() const
Definition: CoffmanGrahamRanking.h:122
ogdf::CoffmanGrahamRanking::_int_set::length
int length() const
Definition: CoffmanGrahamRanking.h:116
ogdf::CoffmanGrahamRanking::m_w
int m_w
Definition: CoffmanGrahamRanking.h:127
ogdf::CoffmanGrahamRanking::_int_set::m_array
int * m_array
Definition: CoffmanGrahamRanking.h:91
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: DfsMakeBiconnected.h:40
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::CoffmanGrahamRanking::_int_set::m_length
int m_length
Definition: CoffmanGrahamRanking.h:92
ogdf::Math::pi
constexpr double pi
The constant .
Definition: Math.h:63
ogdf::CoffmanGrahamRanking::m_s
NodeArray< _int_set > m_s
Definition: CoffmanGrahamRanking.h:128
ogdf::CoffmanGrahamRanking
The coffman graham ranking algorithm.
Definition: CoffmanGrahamRanking.h:57
ogdf::CoffmanGrahamRanking::m_subgraph
std::unique_ptr< AcyclicSubgraphModule > m_subgraph
Definition: CoffmanGrahamRanking.h:126
ogdf::CoffmanGrahamRanking::_int_set
Definition: CoffmanGrahamRanking.h:90
basic.h
Basic declarations, included by all source files.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::AcyclicSubgraphModule
Base class of algorithms for computing a maximal acyclic subgraph.
Definition: AcyclicSubgraphModule.h:47
ogdf::CoffmanGrahamRanking::_int_set::insert
void insert(int x)
Definition: CoffmanGrahamRanking.h:120
ogdf::CoffmanGrahamRanking::_int_set::operator[]
int operator[](int i) const
Definition: CoffmanGrahamRanking.h:118
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240