Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

OGDFFaceWrapper.h
Go to the documentation of this file.
1 
31 #pragma once
32 
33 #ifdef OGDF_INCLUDE_CGAL
34 
37 
38 namespace ogdf {
39 namespace internal {
40 namespace gcm {
41 namespace graph {
42 
46 class OGDFFaceWrapper {
47 private:
48  using Node = node;
49  face m_face;
50  std::shared_ptr<CombinatorialEmbedding> m_ce;
51  std::vector<unsigned int> is_on_flag;
52  std::vector<Node> nodes; //TODO defince cyclic iterator?
53 public:
54  OGDFFaceWrapper() : m_ce(new CombinatorialEmbedding()) { }
55 
56  CombinatorialEmbedding& get_combinatorial_embedding() { return *m_ce; }
57 
58  void set_face(adjEntry external_entry) {
59  set_face(get_combinatorial_embedding().leftFace(external_entry));
60  }
61 
62  void set_face(face _face) {
63  is_on_flag.assign(m_ce->getGraph().maxNodeIndex() + 1, false);
64  m_face = _face;
65  unsigned int c = 1;
66  nodes.clear();
67  for_all_nodes([&](const Node v) {
68  is_on_flag[v->index()] = c++;
69  nodes.push_back(v);
70  });
71  }
72 
73  face ogdf_face() { return m_face; }
74 
75  adjEntry first_adj() { return m_face->firstAdj(); }
76 
77  std::vector<Node>::iterator begin() { return nodes.begin(); }
78 
79  std::vector<Node>::const_iterator begin() const { return nodes.cbegin(); }
80 
81  std::vector<Node>::iterator end() { return nodes.end(); }
82 
83  std::vector<Node>::const_iterator end() const { return nodes.cend(); }
84 
85  template<typename Handler>
86  void for_all_nodes(Handler&& handler) const {
87  adjEntry current = m_face->firstAdj();
88  do {
89  handler(current->theNode());
90  current = current->faceCycleSucc();
91  OGDF_ASSERT(current != nullptr);
92  } while (current != m_face->firstAdj());
93  }
94 
95  bool has_on(Node v) const { return is_on_flag[v->index()]; }
96 
97  unsigned int ordering_number(Node v) const { return is_on_flag[v->index()]; }
98 
99  size_t number_of_nodes() const { return nodes.size(); }
100 };
101 
102 }
103 }
104 }
105 }
106 
107 #endif
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::begin
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
OGDFGraphWrapper.h
ogdf::gml::Key::Node
@ Node
ogdf::adjEntry
AdjElement * adjEntry
The type of adjacency entries.
Definition: Graph_d.h:78
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:70
ogdf::face
FaceElement * face
Definition: CombinatorialEmbedding.h:49
CombinatorialEmbedding.h
Declaration of CombinatorialEmbedding and face.
ogdf::end
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)