Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

CoffmanGrahamRanking.h
Go to the documentation of this file.
1 
33 #pragma once
34 
37 #include <ogdf/basic/NodeArray.h>
38 #include <memory>
39 #include <ogdf/basic/tuples.h>
40 
41 namespace ogdf {
42 
44 
53 
54 public:
57 
58 
64  virtual void call(const Graph &G, NodeArray<int> &rank) override;
66 
67 
73  void setSubgraph(AcyclicSubgraphModule *pSubgraph) {
75  m_subgraph.reset(pSubgraph);
76  }
77 
79 
81  int width() const {
82  return m_w;
83  }
84 
86  void width (int w) {
87  m_w = w;
88  }
89 
90 
91 private:
92  // CoffmanGraham data structures
93  class _int_set {
94  int* m_array;
95  int m_length;
96  int m_index;
97  public:
98  _int_set() : m_array(nullptr), m_length(0), m_index(0) { }
99  explicit _int_set(int len) : m_array(nullptr), m_length(len), m_index(len) {
100  if (len > 0)
101  m_array = new int[m_length];
102  }
103  ~_int_set() { delete[] m_array; }
104 
105  void init(int len) {
106  delete m_array;
107  if ((m_length = len) == 0)
108  m_array = nullptr;
109  else
110  m_array = new int[m_length];
111  m_index = len;
112  }
113 
114  int length() const {
115  return m_length;
116  }
117 
118  int operator[](int i) const {
119  return m_array[i];
120  }
121 
122  void insert(int x) {
123  m_array[--m_index] = x;
124  }
125 
126  bool ready() const {
127  return m_index == 0;
128  }
129  };
130 
131  // CoffmanGraham members
132  std::unique_ptr<AcyclicSubgraphModule> m_subgraph;
133  int m_w;
135 
136  // dfs members
138 
139  // CoffmanGraham funktions
140  void insert (node u, List<Tuple2<node,int> > &ready_nodes);
141  void insert (node u, List<node> &ready, const NodeArray<int> &pi);
142 
143  // dfs funktions
144  void removeTransitiveEdges (Graph& G);
145  void dfs(node v);
146 };
147 
148 }
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
void width(int w)
Set for the with.
int width() const
Get for the with.
constexpr double pi
The constant .
Definition: Math.h:62
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
Declaration of interface for ranking algorithms.
Class for the representation of nodes.
Definition: Graph_d.h:169
Declaration and implementation of NodeArray class.
Base class of algorithms for computing a maximal acyclic subgraph.
std::unique_ptr< AcyclicSubgraphModule > m_subgraph
Declaration and implementation of class Tuple2, Tuple3 and Tuple4.
The coffman graham ranking algorithm.
The namespace for all OGDF objects.
Declaration of interface for acyclic subgraph algorithms.
Interface of algorithms for computing a node ranking.
Definition: RankingModule.h:45