Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

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 #include <ogdf/basic/Stack.h>
41 
42 namespace ogdf {
43 
45 
54 
55 public:
58 
59 
65  virtual void call(const Graph &G, NodeArray<int> &rank) override;
67 
68 
74  void setSubgraph(AcyclicSubgraphModule *pSubgraph) {
76  m_subgraph.reset(pSubgraph);
77  }
78 
80 
82  int width() const {
83  return m_w;
84  }
85 
87  void width (int w) {
88  m_w = w;
89  }
90 
91 
92 private:
93  // CoffmanGraham data structures
94  class _int_set {
95  int *A, l, p;
96  public:
97  _int_set() : A(nullptr), l(0), p(0) { }
98  explicit _int_set(int len) : A(nullptr), l(len), p(len) {
99  if (len > 0)
100  A = new int[l];
101  }
102  ~_int_set() { delete[] A; }
103 
104  void init(int len) {
105  delete A;
106  if ((l = len) == 0)
107  A = nullptr;
108  else
109  A = new int[l];
110  p = len;
111  }
112 
113  int length() const {
114  return l;
115  }
116 
117  int operator[](int i) const {
118  return A[i];
119  }
120 
121  void insert(int x) {
122  A[--p] = x;
123  }
124 
125  bool ready() const {
126  return p == 0;
127  }
128  };
129 
130  // CoffmanGraham members
131  std::unique_ptr<AcyclicSubgraphModule> m_subgraph;
132  int m_w;
134 
135  // 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 
149 } // end namespace ogdf
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
#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.
List-based stacks.
Definition: SList.h:39
Doubly linked lists (maintaining the length of the list).
Definition: List.h:39
Declaration of interface for ranking algorithms.
Class for the representation of nodes.
Definition: Graph_d.h:167
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
Declaration and implementation of list-based stacks (StackPure<E> and Stack<E>).