Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Graph_d.h
Go to the documentation of this file.
1 
35 #pragma once
36 
37 #include <ogdf/basic/GraphList.h>
38 #include <ogdf/basic/Observer.h>
41 
42 #include <array>
43 #include <memory>
44 #include <mutex>
45 
46 #ifdef OGDF_DEBUG
47 # include <set>
48 #endif
49 
50 namespace ogdf {
51 
52 
53 class OGDF_EXPORT Graph;
54 class OGDF_EXPORT NodeElement;
55 class OGDF_EXPORT EdgeElement;
56 class OGDF_EXPORT AdjElement;
57 class OGDF_EXPORT FaceElement;
58 class OGDF_EXPORT ClusterElement;
59 
60 
63 using node = NodeElement*;
64 
67 using edge = EdgeElement*;
68 
72 
73 
74 #if __cpp_concepts >= 201907
75 // clang-format off
76 template<typename T>
77 concept OGDF_NODE_FILTER = requires(T f) {
78  { f(node()) } -> std::convertible_to<bool>;
79 };
80 template<typename T>
81 concept OGDF_EDGE_FILTER = requires(T f) {
82  { f(edge()) } -> std::convertible_to<bool>;
83 };
84 template<typename T>
85 concept OGDF_NODE_ITER = std::forward_iterator<T> && requires(T i) {
86  { *i } -> std::convertible_to<node>;
87 };
88 template<typename T>
89 concept OGDF_EDGE_ITER = std::forward_iterator<T> && requires(T i) {
90  { *i } -> std::convertible_to<edge>;
91 };
92 using std::begin;
93 using std::end;
94 template<typename T>
95 concept OGDF_NODE_LIST = requires(T l) {
96  OGDF_NODE_ITER<decltype(begin(l))>;
97  OGDF_NODE_ITER<decltype(end(l))>;
98 };
99 template<typename T>
100 concept OGDF_EDGE_LIST = requires(T l) {
101  OGDF_EDGE_ITER<decltype(begin(l))>;
102  OGDF_EDGE_ITER<decltype(end(l))>;
103 };
104 // clang-format on
105 
106 # define OGDF_HAS_CONCEPTS
107 # define OGDF_CHECK_CONCEPT static_assert
108 
109 OGDF_CHECK_CONCEPT(OGDF_NODE_ITER<internal::GraphIterator<node>>);
110 OGDF_CHECK_CONCEPT(OGDF_EDGE_ITER<internal::GraphIterator<edge>>);
111 OGDF_CHECK_CONCEPT(OGDF_NODE_ITER<internal::GraphReverseIterator<node>>);
112 OGDF_CHECK_CONCEPT(OGDF_EDGE_ITER<internal::GraphReverseIterator<edge>>);
113 OGDF_CHECK_CONCEPT(OGDF_NODE_LIST<internal::GraphObjectContainer<NodeElement>>);
114 OGDF_CHECK_CONCEPT(OGDF_EDGE_LIST<internal::GraphObjectContainer<EdgeElement>>);
115 OGDF_CHECK_CONCEPT(OGDF_NODE_ITER<ListIteratorBase<node, false, false>>);
116 OGDF_CHECK_CONCEPT(OGDF_EDGE_ITER<ListIteratorBase<edge, false, true>>);
117 OGDF_CHECK_CONCEPT(OGDF_NODE_ITER<ListIteratorBase<node, true, false>>);
118 OGDF_CHECK_CONCEPT(OGDF_EDGE_ITER<ListIteratorBase<edge, true, false>>);
119 #else
120 # define OGDF_NODE_FILTER typename
121 # define OGDF_EDGE_FILTER typename
122 # define OGDF_NODE_ITER typename
123 # define OGDF_EDGE_ITER typename
124 # define OGDF_NODE_LIST typename
125 # define OGDF_EDGE_LIST typename
126 
127 # define OGDF_CHECK_CONCEPT(...)
128 #endif
129 
131 
136  friend class Graph;
139 
143  int m_id;
144 
146  explicit AdjElement(node v) : m_twin(nullptr), m_edge(nullptr), m_node(v), m_id(0) { }
147 
149  AdjElement(edge e, int id) : m_twin(nullptr), m_edge(e), m_node(nullptr), m_id(id) { }
150 
151 public:
153  edge theEdge() const { return m_edge; }
154 
156  operator edge() const { return m_edge; }
157 
159  node theNode() const { return m_node; }
160 
162  operator node() const { return m_node; }
163 
165  adjEntry twin() const { return m_twin; }
166 
168  node twinNode() const { return m_twin->m_node; }
169 
171  int index() const { return m_id; }
172 
174  bool isSource() const;
175 
186  bool isBetween(adjEntry adjBefore, adjEntry adjAfter) const;
187 
188  // traversing faces in clockwise (resp. counter-clockwise) order
189  // (if face is an interior face)
190 
192  adjEntry clockwiseFaceSucc() const { return m_twin->cyclicPred(); }
193 
195  adjEntry clockwiseFacePred() const { return cyclicSucc()->m_twin; }
196 
198  adjEntry counterClockwiseFaceSucc() const { return m_twin->cyclicSucc(); }
199 
201  adjEntry counterClockwiseFacePred() const { return cyclicPred()->m_twin; }
202 
203  // default is traversing faces in clockwise order
205  adjEntry faceCycleSucc() const { return clockwiseFaceSucc(); }
206 
208  adjEntry faceCyclePred() const { return clockwiseFacePred(); }
209 
211  adjEntry succ() const { return static_cast<adjEntry>(m_next); }
212 
214  adjEntry pred() const { return static_cast<adjEntry>(m_prev); }
215 
217  adjEntry cyclicSucc() const;
219  adjEntry cyclicPred() const;
220 
221 #ifdef OGDF_DEBUG
222  const Graph* graphOf() const;
223 #endif
224 
226  static int compare(const AdjElement& x, const AdjElement& y) { return x.m_id - y.m_id; }
228 
230 };
231 
234  friend class Graph;
236 
237  //GraphList<AdjElement> m_adjEdges; //!< The adjacency list of the node.
238  int m_indeg;
239  int m_outdeg;
240  int m_id;
241 
242 #ifdef OGDF_DEBUG
243  // we store the graph containing this node for debugging purposes
244  const Graph* m_pGraph;
245 #endif
246 
247 
249 #ifdef OGDF_DEBUG
250 
255  NodeElement(const Graph* pGraph, int id)
256  : m_indeg(0), m_outdeg(0), m_id(id), m_pGraph(pGraph) { }
257 #else
258  NodeElement(int id) : m_indeg(0), m_outdeg(0), m_id(id) { }
259 #endif
260 
261 
262 public:
265 
267  int index() const { return m_id; }
268 
270  int indeg() const { return m_indeg; }
271 
273  int outdeg() const { return m_outdeg; }
274 
276  int degree() const { return m_indeg + m_outdeg; }
277 
279  adjEntry firstAdj() const { return adjEntries.head(); }
280 
282  adjEntry lastAdj() const { return adjEntries.tail(); }
283 
285  node succ() const { return static_cast<node>(m_next); }
286 
288  node pred() const { return static_cast<node>(m_prev); }
289 
291 
295  template<class ADJLIST>
296  void allAdjEntries(ADJLIST& adjList) const {
297  adjList.clear();
298  for (adjEntry adj : this->adjEntries) {
299  adjList.pushBack(adj);
300  }
301  }
302 
304 
311  template<class EDGELIST>
312  void adjEdges(EDGELIST& edgeList) const {
313  edgeList.clear();
314  for (adjEntry adj : this->adjEntries) {
315  edgeList.pushBack(adj->theEdge());
316  }
317  }
318 
320 
324  template<class EDGELIST>
325  void inEdges(EDGELIST& edgeList) const;
326 
328 
332  template<class EDGELIST>
333  void outEdges(EDGELIST& edgeList) const;
334 
335 #ifdef OGDF_DEBUG
336  const Graph* graphOf() const { return m_pGraph; }
338 #endif
339 
341  static int compare(const NodeElement& x, const NodeElement& y) { return x.m_id - y.m_id; }
343 
345 };
346 
348  return (m_next) ? static_cast<adjEntry>(m_next) : m_node->firstAdj();
349 }
350 
352  return (m_prev) ? static_cast<adjEntry>(m_prev) : m_node->lastAdj();
353 }
354 
357  friend class Graph;
359 
364  int m_id; // The (unique) index of the edge.
365 
367 
374  EdgeElement(node src, node tgt, AdjElement* adjSrc, AdjElement* adjTgt, int id)
375  : m_src(src), m_tgt(tgt), m_adjSrc(adjSrc), m_adjTgt(adjTgt), m_id(id) { }
376 
378 
383  EdgeElement(node src, node tgt, int id)
384  : m_src(src), m_tgt(tgt), m_adjSrc(nullptr), m_adjTgt(nullptr), m_id(id) { }
385 
386 public:
388  int index() const { return m_id; }
389 
391  node source() const { return m_src; }
392 
394  node target() const { return m_tgt; }
395 
397  std::array<node, 2> nodes() const { return std::array<node, 2> {{m_src, m_tgt}}; }
398 
400  adjEntry adjSource() const { return m_adjSrc; }
401 
403  adjEntry adjTarget() const { return m_adjTgt; }
404 
406  node opposite(node v) const {
407  OGDF_ASSERT(isIncident(v));
408  return v == m_src ? m_tgt : m_src;
409  }
410 
412  bool isSelfLoop() const { return m_src == m_tgt; }
413 
415  bool isInvertedDirected(edge e) const { return m_src == e->target() && m_tgt == e->source(); }
416 
418  bool isParallelDirected(edge e) const { return m_src == e->source() && m_tgt == e->target(); }
419 
421  bool isParallelUndirected(edge e) const {
422  return isParallelDirected(e) || isInvertedDirected(e);
423  }
424 
426  edge succ() const { return static_cast<edge>(m_next); }
427 
429  edge pred() const { return static_cast<edge>(m_prev); }
430 
431 #ifdef OGDF_DEBUG
432  const Graph* graphOf() const { return m_src->graphOf(); }
434 #endif
435 
437  bool isIncident(node v) const { return v == m_src || v == m_tgt; }
438 
440  bool isAdjacent(edge e) const { return isIncident(e->m_src) || isIncident(e->m_tgt); }
441 
443  node commonNode(edge e) const {
444  return (m_src == e->m_src || m_src == e->m_tgt)
445  ? m_src
446  : ((m_tgt == e->m_src || m_tgt == e->m_tgt) ? m_tgt : nullptr);
447  }
448 
451  adjEntry getAdj(node v) const {
452  OGDF_ASSERT(this->isIncident(v));
453  return v == m_src ? m_adjSrc : m_adjTgt;
454  }
455 
457  static int compare(const EdgeElement& x, const EdgeElement& y) { return x.m_id - y.m_id; }
459 
461 
462 #ifdef OGDF_DEBUG
463 private:
464  bool m_hidden = false;
465 #endif
466 };
467 
468 #ifdef OGDF_DEBUG
469 inline const Graph* AdjElement::graphOf() const { return m_node->graphOf(); }
470 #endif
471 
472 inline bool AdjElement::isSource() const { return this == m_edge->adjSource(); }
473 
474 inline bool AdjElement::isBetween(adjEntry adjBefore, adjEntry adjAfter) const {
475 #ifdef OGDF_DEBUG
476  node v = this->theNode();
477  OGDF_ASSERT(adjBefore->theNode() == v);
478  OGDF_ASSERT(adjAfter->theNode() == v);
479 #endif
480  bool result = this != adjBefore && this != adjAfter && adjBefore != adjAfter;
481 
482  if (result) {
483  adjEntry adj = adjBefore;
484  for (; adj != this && adj != adjAfter; adj = adj->cyclicSucc()) {
485  ;
486  }
487  result = adj == this;
488  }
489 
490  return result;
491 }
492 
493 template<class EDGELIST>
494 void NodeElement::inEdges(EDGELIST& edgeList) const {
495  edgeList.clear();
496  for (adjEntry adj : this->adjEntries) {
497  edge e = adj->theEdge();
498  if (adj == e->adjTarget()) {
499  edgeList.pushBack(e);
500  }
501  }
502 }
503 
504 template<class EDGELIST>
505 void NodeElement::outEdges(EDGELIST& edgeList) const {
506  edgeList.clear();
507  for (adjEntry adj : this->adjEntries) {
508  edge e = adj->theEdge();
509  if (adj == e->adjSource()) {
510  edgeList.pushBack(e);
511  }
512  }
513 }
514 
519 
520 public:
523 
525  GraphAdjIterator(Graph* graph = nullptr, adjEntry entry = nullptr);
526 
529 
531  GraphAdjIterator end() { return GraphAdjIterator(m_pGraph); }
532 
534  void next();
535 
537  void prev();
538 
540  adjEntry operator*() const { return m_entry; }
541 
543  AdjElement& operator->() const { return *m_entry; }
544 
546  bool operator==(const GraphAdjIterator& iter) const {
547  return m_pGraph == iter.m_pGraph && m_entry == iter.m_entry;
548  }
549 
551  bool operator!=(const GraphAdjIterator& iter) const { return !operator==(iter); }
552 
555  next();
556  return *this;
557  }
558 
561  GraphAdjIterator iter = *this;
562  next();
563  return iter;
564  }
565 
568  prev();
569  return *this;
570  }
571 
574  GraphAdjIterator iter = *this;
575  prev();
576  return iter;
577  }
578 };
579 
580 namespace internal {
582 
589 template<typename Key, typename Iterable = GraphObjectContainer<Key>, int Factor = 1>
591  : public RegistryBase<Key*, GraphRegistry<Key, Iterable, Factor>, typename Iterable::iterator> {
594 
595 public:
596  using iterator = typename Iterable::iterator;
597 
599  GraphRegistry(Graph* graph, int* nextKeyIndex)
600  : m_pGraph(graph), m_nextKeyIndex(nextKeyIndex) { }
601 
602  static inline int keyToIndex(Key* key) { return key->index(); }
603 
604  bool isKeyAssociated(Key* key) const {
605  if (key == nullptr) {
606  return false;
607  }
608 #ifdef OGDF_DEBUG
609  if (key->graphOf() == m_pGraph) {
610  OGDF_ASSERT(keyToIndex(key) < this->getArraySize());
611  return true;
612  } else {
613  return false;
614  }
615 #else
616  return true;
617 #endif
618  }
619 
620  int calculateArraySize(int add) const {
621  return calculateTableSize((*m_nextKeyIndex + add) * Factor);
622  }
623 
624  int maxKeyIndex() const { return ((*m_nextKeyIndex) * Factor) - 1; }
625 
627  Graph* graphOf() const { return m_pGraph; }
628 };
629 
633 
634 #ifndef DOXYGEN_IGNORE
635 // doxygen has problems keeping these methods apart
637 
639 
641 
643 
645 
647 #endif
648 
650 template<typename Key, typename Value, bool WithDefault, typename Registry = GraphRegistry<Key>>
651 class GraphRegisteredArray : public RegisteredArray<Registry, Value, WithDefault, Graph> {
653 
654 public:
655  using RA::RA;
656 
658  Graph* graphOf() const {
659  if (RA::registeredAt() == nullptr) {
660  return nullptr;
661  } else {
662  return RA::registeredAt()->graphOf();
663  }
664  }
665 };
666 
668 template<typename Value, bool WithDefault>
669 class EdgeArrayBase1 : public GraphRegisteredArray<EdgeElement, Value, WithDefault> {
671 
672 public:
673  using GRA::GRA;
674 
675  using GRA::operator[];
676  using GRA::operator();
677 
679  const Value& operator[](adjEntry adj) const {
680  OGDF_ASSERT(adj != nullptr);
681  OGDF_ASSERT(GRA::getRegistry().isKeyAssociated(adj->theEdge()));
682  return GRA::operator[](adj->index() >> 1);
683  }
684 
686  Value& operator[](adjEntry adj) {
687  OGDF_ASSERT(adj != nullptr);
688  OGDF_ASSERT(GRA::getRegistry().isKeyAssociated(adj->theEdge()));
689  return GRA::operator[](adj->index() >> 1);
690  }
691 
693  const Value& operator()(adjEntry adj) const {
694  OGDF_ASSERT(adj != nullptr);
695  OGDF_ASSERT(GRA::getRegistry().isKeyAssociated(adj->theEdge()));
696  return GRA::operator[](adj->index() >> 1);
697  }
698 
700  Value& operator()(adjEntry adj) {
701  OGDF_ASSERT(adj != nullptr);
702  OGDF_ASSERT(GRA::getRegistry().isKeyAssociated(adj->theEdge()));
703  return GRA::operator[](adj->index() >> 1);
704  }
705 };
706 
708 template<typename Value, bool WithDefault>
709 class EdgeArrayBase2 : public EdgeArrayBase1<Value, WithDefault> {
710 public:
712 };
713 
714 template<bool WithDefault>
715 class EdgeArrayBase2<edge, WithDefault> : public EdgeArrayBase1<edge, WithDefault> {
717 
718 public:
719  using EA::EA;
720 
723  OGDF_ASSERT(adj != nullptr);
724  OGDF_ASSERT(EA::getRegistry().isKeyAssociated(adj->theEdge()));
725  edge e = EA::operator[](adj->index() >> 1);
726  return adj->isSource() ? e->adjSource() : e->adjTarget();
727  }
728 };
729 }
730 
731 #define OGDF_DECL_REG_ARRAY_TYPE(v, c) internal::GraphRegisteredArray<NodeElement, v, c>
734 #undef OGDF_DECL_REG_ARRAY_TYPE
735 
736 #define OGDF_DECL_REG_ARRAY_TYPE(v, c) internal::EdgeArrayBase2<v, c>
739 #undef OGDF_DECL_REG_ARRAY_TYPE
740 
741 #define OGDF_DECL_REG_ARRAY_TYPE(v, c) \
742  internal::GraphRegisteredArray<AdjElement, v, c, internal::GraphAdjRegistry>
745 #undef OGDF_DECL_REG_ARRAY_TYPE
746 
747 template<bool>
748 class EdgeSet;
749 
751 
770 class OGDF_EXPORT GraphObserver : public Observer<Graph, GraphObserver> {
771 public:
773  GraphObserver() = default;
774 
779  explicit GraphObserver(const Graph* G) { reregister(G); }
780 
782  virtual void nodeDeleted(node v) = 0;
783 
785  virtual void nodeAdded(node v) = 0;
786 
788  virtual void edgeDeleted(edge e) = 0;
789 
791  virtual void edgeAdded(edge e) = 0;
792 
794  virtual void cleared() = 0;
795 
796  const Graph* getGraph() const { return getObserved(); }
797 };
798 
799 namespace internal {
800 template<typename CONTAINER>
801 inline void getAllNodes(const Graph& G, CONTAINER& nodes);
802 template<typename CONTAINER>
803 inline void getAllEdges(const Graph& G, CONTAINER& edges);
804 
805 inline node adjToNode(adjEntry adj) { return adj->theNode(); }
806 
807 inline node adjToNode(node n) { return n; }
808 }
809 
811 OGDF_EXPORT bool filter_any_edge(edge e); // { return true; }
812 
814 OGDF_EXPORT bool filter_any_node(node n); // { return true; }
815 
817 
862 class OGDF_EXPORT Graph : public Observable<GraphObserver, Graph> {
863 public:
864  class HiddenEdgeSet;
865  class CCsInfo;
866  friend class GraphObserver;
867 
868 private:
871 
875 
877 
878 public:
884 
892 
894 
898 
901  enum class EdgeType { association = 0, generalization = 1, dependency = 2 };
902 
904  enum class NodeType {
905  vertex = 0,
906  dummy = 1,
907  generalizationMerger = 2,
908  generalizationExpander = 3,
909  highDegreeExpander = 4,
910  lowDegreeExpander = 5,
911  associationClass = 6
912  };
913 
915 
916 
921 
925 
928 
930 
931 
933  Graph();
934 
936 
945 
947 
957 
959 
961  virtual ~Graph();
962 
964 
968 
971  bool empty() const { return nodes.empty(); }
972 
974  int numberOfNodes() const { return nodes.size(); }
975 
977  int numberOfEdges() const { return edges.size(); }
978 
980  int maxNodeIndex() const { return m_nodeIdCount - 1; }
981 
983  int maxEdgeIndex() const { return m_edgeIdCount - 1; }
984 
986  int maxAdjEntryIndex() const { return (m_edgeIdCount << 1) - 1; }
987 
989  node firstNode() const { return nodes.head(); }
990 
992  node lastNode() const { return nodes.tail(); }
993 
995  edge firstEdge() const { return edges.head(); }
996 
998  edge lastEdge() const { return edges.tail(); }
999 
1007  node chooseNode(
1008  std::function<bool(node)> includeNode = [](node) { return true; },
1009  bool isFastTest = true) const;
1010 
1018  edge chooseEdge(
1019  std::function<bool(edge)> includeEdge = [](edge) { return true; },
1020  bool isFastTest = true) const;
1021 
1023 
1027  template<class CONTAINER>
1028  void allNodes(CONTAINER& nodeContainer) const {
1029  internal::getAllNodes<CONTAINER>(*this, nodeContainer);
1030  }
1031 
1033 
1037  template<class CONTAINER>
1038  void allEdges(CONTAINER& edgeContainer) const {
1039  internal::getAllEdges<CONTAINER>(*this, edgeContainer);
1040  }
1041 
1043 
1046 
1049 
1056  node newNode(int index = -1) {
1057  node v = pureNewNode(index);
1058  m_regNodeArrays.keyAdded(v);
1059  for (GraphObserver* obs : getObservers()) {
1060  obs->nodeAdded(v);
1061  }
1062  return v;
1063  }
1064 
1066 
1075  inline edge newEdge(node v, node w, int index = -1) {
1076  return newEdge(v, Direction::after, w, Direction::after, index);
1077  }
1078 
1080 
1094  inline edge newEdge(node v, adjEntry adjTgt, int index = -1) {
1095  return newEdge(v, Direction::after, adjTgt, Direction::after, index);
1096  }
1097 
1099 
1113  inline edge newEdge(adjEntry adjSrc, node w, int index = -1) {
1114  return newEdge(adjSrc, Direction::after, w, Direction::after, index);
1115  }
1116 
1118 
1135  inline edge newEdge(adjEntry adjSrc, adjEntry adjTgt, Direction dir = Direction::after,
1136  int index = -1) {
1137  return newEdge(adjSrc, dir, adjTgt, dir, index);
1138  }
1139 
1141 
1159  template<typename S, typename T>
1160  edge newEdge(S src, Direction dirSrc, T tgt, Direction dirTgt, int index = -1) {
1161  OGDF_ASSERT(src != nullptr);
1162  OGDF_ASSERT(tgt != nullptr);
1163  edge e = pureNewEdge(internal::adjToNode(src), internal::adjToNode(tgt), index);
1164 
1165  insertAdjEntry(tgt, e->m_adjTgt, dirTgt);
1166  insertAdjEntry(src, e->m_adjSrc, dirSrc);
1167 
1168  m_regEdgeArrays.keyAdded(e);
1169  m_regAdjArrays.keyAdded(e->adjSource());
1170  for (GraphObserver* obs : getObservers()) {
1171  obs->edgeAdded(e);
1172  }
1173 
1174  return e;
1175  }
1176 
1178 
1181 
1184  virtual void delNode(node v);
1185 
1187  virtual void delEdge(edge e);
1188 
1190  virtual void clear();
1191 
1193  void restoreAllEdges();
1194 
1196 
1217  friend class Graph;
1218  friend class EdgeElement;
1219 
1220  public:
1226  explicit HiddenEdgeSet(Graph& graph) : m_graph(&graph) {
1227  m_it = m_graph->m_hiddenEdgeSets.pushFront(this);
1228  }
1229 
1234  if (m_graph) {
1235  restore();
1236  m_graph->m_hiddenEdgeSets.del(m_it);
1237  }
1238  }
1239 
1246  void hide(edge e);
1247 
1254  void restore(edge e);
1255 
1262  void restore();
1263 
1265  int size();
1266 
1268  bool empty();
1269 
1272 
1275 
1276  private:
1280 
1282  };
1283 
1287 
1290 
1299  virtual edge split(edge e);
1300 
1302 
1311  void unsplit(node u);
1312 
1314 
1325  virtual void unsplit(edge eIn, edge eOut);
1326 
1328 
1349  node splitNode(adjEntry adjStartLeft, adjEntry adjStartRight);
1350 
1352 
1360  node contract(edge e, bool keepSelfLoops = false);
1361 
1363 
1377  void move(edge e, adjEntry adjSrc, Direction dirSrc, adjEntry adjTgt, Direction dirTgt);
1378 
1380 
1386  void moveTarget(edge e, node w);
1387 
1389 
1397  void moveTarget(edge e, adjEntry adjTgt, Direction dir);
1398 
1400 
1406  void moveSource(edge e, node w);
1407 
1409 
1417  void moveSource(edge e, adjEntry adjSrc, Direction dir);
1418 
1420 
1428  edge searchEdge(node v, node w, bool directed = false) const;
1429 
1431  void reverseEdge(edge e);
1432 
1434  void reverseAllEdges();
1435 
1437 
1443  template<class NODELIST>
1444  void collapse(NODELIST& nodesToCollapse) {
1445  node v = nodesToCollapse.popFrontRet();
1446  while (!nodesToCollapse.empty()) {
1447  node w = nodesToCollapse.popFrontRet();
1448  adjEntry adj = w->firstAdj();
1449  while (adj != nullptr) {
1450  adjEntry succ = adj->succ();
1451  edge e = adj->theEdge();
1452  if (e->source() == v || e->target() == v) {
1453  delEdge(e);
1454  } else if (e->source() == w) {
1455  moveSource(e, v);
1456  } else {
1457  moveTarget(e, v);
1458  }
1459  adj = succ;
1460  }
1461  delNode(w);
1462  }
1463  }
1464 
1466 
1473  template<class ADJ_ENTRY_LIST>
1474  void sort(node v, const ADJ_ENTRY_LIST& newOrder) {
1475  using std::begin;
1476  using std::end;
1477  sort(v, begin(newOrder), end(newOrder));
1478  }
1479 
1481 
1489  template<class IT>
1490  void sort(node v, IT begin, IT end) {
1491 #ifdef OGDF_DEBUG
1492  std::set<int> entries;
1493  int counter = 0;
1494 
1495  for (auto it = begin; it != end; ++it) {
1496  adjEntry adj = *it;
1497  entries.insert(adj->index());
1498  OGDF_ASSERT(adj->theNode() == v);
1499  counter++;
1500  }
1501 
1502  OGDF_ASSERT(counter == v->degree());
1503  OGDF_ASSERT(entries.size() == static_cast<unsigned int>(v->degree()));
1504 #endif
1505  v->adjEntries.sort(begin, end);
1506  }
1507 
1509 
1512  void reverseAdjEdges(node v) { v->adjEntries.reverse(); }
1513 
1515 
1522  void moveAdj(adjEntry adjMove, Direction dir, adjEntry adjPos) {
1523  OGDF_ASSERT(adjMove != nullptr);
1524  OGDF_ASSERT(adjPos != nullptr);
1525  OGDF_ASSERT(adjMove->graphOf() == this);
1526  OGDF_ASSERT(adjPos->graphOf() == this);
1527  internal::GraphList<AdjElement>& adjList = adjMove->m_node->adjEntries;
1528  adjList.move(adjMove, adjList, adjPos, dir);
1529  }
1530 
1532 
1538  void moveAdjAfter(adjEntry adjMove, adjEntry adjAfter) {
1539  OGDF_ASSERT(adjMove != nullptr);
1540  OGDF_ASSERT(adjAfter != nullptr);
1541  OGDF_ASSERT(adjMove->graphOf() == this);
1542  OGDF_ASSERT(adjAfter->graphOf() == this);
1543  adjMove->m_node->adjEntries.moveAfter(adjMove, adjAfter);
1544  }
1545 
1547 
1553  void moveAdjBefore(adjEntry adjMove, adjEntry adjBefore) {
1554  OGDF_ASSERT(adjMove != nullptr);
1555  OGDF_ASSERT(adjBefore != nullptr);
1556  OGDF_ASSERT(adjMove->graphOf() == this);
1557  OGDF_ASSERT(adjBefore->graphOf() == this);
1558  adjMove->m_node->adjEntries.moveBefore(adjMove, adjBefore);
1559  }
1560 
1562  void reverseAdjEdges();
1563 
1565 
1571  void swapAdjEdges(adjEntry adj1, adjEntry adj2) {
1572  OGDF_ASSERT(adj1->theNode() == adj2->theNode());
1573  OGDF_ASSERT(adj1->graphOf() == this);
1574 
1575  adj1->theNode()->adjEntries.swap(adj1, adj2);
1576  }
1577 
1579 
1582 
1585 
1595  int genus() const;
1596 
1598 
1601  bool representsCombEmbedding() const { return genus() == 0; }
1602 
1603 #ifdef OGDF_DEBUG
1604  void consistencyCheck() const;
1606 #endif
1607 
1609 
1614 
1617  internal::GraphNodeRegistry& nodeRegistry() { return m_regNodeArrays; }
1618 
1620  const internal::GraphNodeRegistry& nodeRegistry() const { return m_regNodeArrays; }
1621 
1622  operator const internal::GraphNodeRegistry&() const { return m_regNodeArrays; }
1623 
1625  internal::GraphEdgeRegistry& edgeRegistry() { return m_regEdgeArrays; }
1626 
1628  const internal::GraphEdgeRegistry& edgeRegistry() const { return m_regEdgeArrays; }
1629 
1630  operator const internal::GraphEdgeRegistry&() const { return m_regEdgeArrays; }
1631 
1633  internal::GraphAdjRegistry& adjEntryRegistry() { return m_regAdjArrays; }
1634 
1636  const internal::GraphAdjRegistry& adjEntryRegistry() const { return m_regAdjArrays; }
1637 
1638  operator const internal::GraphAdjRegistry&() const { return m_regAdjArrays; }
1639 
1641 
1666  void resetEdgeIdCount(int maxId);
1667 
1668  void resetNodeIdCount(int maxId);
1669 
1670 
1672 
1675 
1710  template<OGDF_NODE_ITER NI, OGDF_EDGE_ITER EI, bool copyEmbedding = true, bool copyIDs = false,
1711  bool notifyObservers = true>
1712  std::pair<int, int> insert(const NI& nodesBegin, const NI& nodesEnd, const EI& edgesBegin,
1713  const EI& edgesEnd, NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap);
1714 
1742  template<OGDF_NODE_ITER NI, OGDF_EDGE_FILTER EF, bool copyIDs = false, bool notifyObservers = true>
1743  std::pair<int, int> insert(const NI& nodesBegin, const NI& nodesEnd, const EF& edgeFilter,
1744  NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap);
1745 
1746  // List short-cuts
1747 
1754  template<OGDF_NODE_LIST NL>
1755  std::pair<int, int> insert(const NL& nodeList, const EdgeSet<true>& edgeSet,
1756  NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap);
1757 
1764  template<OGDF_NODE_LIST NL>
1765  std::pair<int, int> insert(const NL& nodeList, const EdgeSet<false>& edgeSet,
1766  NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap);
1767 
1774  template<OGDF_NODE_LIST NL, OGDF_EDGE_LIST EL>
1775  std::pair<int, int> insert(const NL& nodeList, const EL& edgeList, NodeArray<node>& nodeMap,
1776  EdgeArray<edge>& edgeMap) {
1777  m_regNodeArrays.reserveSpace(nodeList.size());
1778  m_regEdgeArrays.reserveSpace(edgeList.size());
1779  m_regAdjArrays.reserveSpace(edgeList.size());
1780  using std::begin;
1781  using std::end;
1782  return insert(begin(nodeList), end(nodeList), begin(edgeList), end(edgeList), nodeMap,
1783  edgeMap);
1784  }
1785 
1786  // Often-used special cases
1787 
1794  std::pair<int, int> insert(const CCsInfo& info, int cc, NodeArray<node>& nodeMap,
1795  EdgeArray<edge>& edgeMap) {
1796  OGDF_ASSERT(&(info.constGraph()) == nodeMap.registeredAt()->graphOf());
1797  OGDF_ASSERT(&(info.constGraph()) == edgeMap.registeredAt()->graphOf());
1798  m_regNodeArrays.reserveSpace(info.numberOfNodes(cc));
1799  m_regEdgeArrays.reserveSpace(info.numberOfEdges(cc));
1800  m_regAdjArrays.reserveSpace(info.numberOfEdges(cc));
1801  auto count = insert(info.nodes(cc).begin(), info.nodes(cc).end(), filter_any_edge, nodeMap,
1802  edgeMap);
1803  OGDF_ASSERT(count.first == info.numberOfNodes(cc));
1804  OGDF_ASSERT(count.second == info.numberOfEdges(cc));
1805  return count;
1806  }
1807 
1814  std::pair<int, int> insert(const Graph& G, NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap) {
1815  if (!nodeMap.registeredAt()) {
1816  nodeMap.init(G);
1817  }
1818  OGDF_ASSERT(nodeMap.registeredAt()->graphOf() == &G);
1819  if (!edgeMap.registeredAt()) {
1820  edgeMap.init(G);
1821  }
1822  OGDF_ASSERT(edgeMap.registeredAt()->graphOf() == &G);
1823  m_regNodeArrays.reserveSpace(G.numberOfNodes());
1824  m_regEdgeArrays.reserveSpace(G.numberOfEdges());
1825  m_regAdjArrays.reserveSpace(G.numberOfEdges());
1826  auto count = insert(G.nodes.begin(), G.nodes.end(), filter_any_edge, nodeMap, edgeMap);
1827  OGDF_ASSERT(count.first == G.numberOfNodes());
1828  OGDF_ASSERT(count.second == G.numberOfEdges());
1829  return count;
1830  }
1831 
1838  std::pair<int, int> insert(const Graph& G) {
1839  NodeArray<node> nodeMap(G, nullptr);
1840  EdgeArray<edge> edgeMap(G, nullptr);
1841  return insert(G, nodeMap, edgeMap);
1842  }
1843 
1844 private:
1845  template<OGDF_NODE_ITER NI, bool notifyObservers, bool copyIDs>
1846  void insertNodes(const NI& nodesBegin, const NI& nodesEnd, NodeArray<node, true>& nodeMap,
1847  int& newNodes, void* cbData);
1848 
1849 protected:
1865  virtual void* preInsert(bool copyEmbedding, bool copyIDs, bool notifyObservers, bool edgeFilter,
1866  NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap, int* newNodes, int* newEdges) {
1867  return nullptr;
1868  };
1869 
1877  virtual void nodeInserted(void* userData, node original, node copy) {};
1878 
1886  virtual void edgeInserted(void* userData, edge original, edge copy) {};
1887 
1895  virtual void postInsert(void* userData, int newNodes, int newEdges) {};
1897 
1898 public:
1901  const Graph* m_graph;
1902  int m_numCC;
1903 
1908 
1909  public:
1911  CCsInfo() : m_graph(nullptr), m_numCC(0) { }
1912 
1914  explicit CCsInfo(const Graph& G);
1915 
1917  const Graph& constGraph() const { return *m_graph; }
1918 
1920  int numberOfCCs() const { return m_numCC; }
1921 
1923  int numberOfNodes(int cc) const { return stopNode(cc) - startNode(cc); }
1924 
1926  int numberOfEdges(int cc) const { return stopEdge(cc) - startEdge(cc); }
1927 
1929  int startNode(int cc) const { return m_startNode[cc]; }
1930 
1932  int stopNode(int cc) const { return m_startNode[cc + 1]; }
1933 
1935  return {m_nodes.begin() + startNode(cc), m_nodes.begin() + stopNode(cc)};
1936  }
1937 
1939  return {m_edges.begin() + startEdge(cc), m_edges.begin() + stopEdge(cc)};
1940  }
1941 
1943  int startEdge(int cc) const { return m_startEdge[cc]; }
1944 
1946  int stopEdge(int cc) const { return m_startEdge[cc + 1]; }
1947 
1949  node v(int i) const { return m_nodes[i]; }
1950 
1952  edge e(int i) const { return m_edges[i]; }
1953  };
1954 
1955 private:
1963  inline node pureNewNode(int index) {
1964  if (index < 0) {
1965  index = m_nodeIdCount++;
1966  } else {
1967  m_nodeIdCount = max(m_nodeIdCount, index + 1);
1968  }
1969 
1970  // simple check against illegal index reuse
1971  OGDF_ASSERT(nodes.empty() || index != nodes.head()->index());
1972  OGDF_ASSERT(nodes.empty() || index != nodes.tail()->index());
1973 
1974 #ifdef OGDF_DEBUG
1975  node v = new NodeElement(this, index);
1976 #else
1977  node v = new NodeElement(index);
1978 #endif
1979  nodes.pushBack(v);
1980  return v;
1981  }
1982 
1994  edge pureNewEdge(node src, node tgt, int index) {
1995  OGDF_ASSERT(src != nullptr);
1996  OGDF_ASSERT(tgt != nullptr);
1997  OGDF_ASSERT(src->graphOf() == this);
1998  OGDF_ASSERT(tgt->graphOf() == this);
1999 
2000  if (index < 0) {
2001  index = m_edgeIdCount++;
2002  } else {
2003  m_edgeIdCount = max(m_edgeIdCount, index + 1);
2004  }
2005 
2006  // simple check against illegal index reuse
2007  OGDF_ASSERT(edges.empty() || index != edges.head()->index());
2008  OGDF_ASSERT(edges.empty() || index != edges.tail()->index());
2009 
2010  edge e = new EdgeElement(src, tgt, index);
2011  edges.pushBack(e);
2012 
2013  e->m_adjSrc = new AdjElement(e, index << 1);
2014  e->m_adjTgt = new AdjElement(e, (index << 1) | 1);
2015 
2016  e->m_adjSrc->m_twin = e->m_adjTgt;
2017  e->m_adjSrc->m_node = src;
2018  src->m_outdeg++;
2019 
2020  e->m_adjTgt->m_twin = e->m_adjSrc;
2021  e->m_adjTgt->m_node = tgt;
2022  tgt->m_indeg++;
2023 
2024  return e;
2025  }
2026 
2027  static inline void insertAdjEntry(adjEntry oldAdj, adjEntry newAdj, Direction dir) {
2028  if (dir == Direction::after) {
2029  oldAdj->theNode()->adjEntries.insertAfter(newAdj, oldAdj);
2030  } else {
2031  oldAdj->theNode()->adjEntries.insertBefore(newAdj, oldAdj);
2032  }
2033  }
2034 
2035  static inline void insertAdjEntry(node n, adjEntry newAdj, Direction dir) {
2036  if (dir == Direction::after || n->adjEntries.empty()) {
2037  n->adjEntries.pushBack(newAdj);
2038  } else {
2039  n->adjEntries.insertBefore(newAdj, n->adjEntries.head());
2040  }
2041  }
2042 
2044  void moveAdj(adjEntry adj, node w);
2045 };
2046 
2047 OGDF_EXPORT std::ostream& operator<<(std::ostream& os, const Graph::EdgeType& et);
2048 
2051 public:
2053  int getBucket(const edge& e) override { return e->source()->index(); }
2054 };
2055 
2058 public:
2060  int getBucket(const edge& e) override { return e->target()->index(); }
2061 };
2062 
2063 namespace internal {
2064 
2065 template<typename CONTAINER>
2066 inline void getAllNodes(const Graph& G, CONTAINER& nodes) {
2067  nodes.clear();
2068  for (node v : G.nodes) {
2069  nodes.pushBack(v);
2070  }
2071 }
2072 
2073 template<>
2074 inline void getAllNodes(const Graph& G, Array<node>& nodes) {
2075  nodes.init(G.numberOfNodes());
2076  int i = 0;
2077  for (node v : G.nodes) {
2078  nodes[i++] = v;
2079  }
2080 }
2081 
2082 template<typename CONTAINER>
2083 inline void getAllEdges(const Graph& G, CONTAINER& edges) {
2084  edges.clear();
2085  for (edge v : G.edges) {
2086  edges.pushBack(v);
2087  }
2088 }
2089 
2090 template<>
2091 inline void getAllEdges(const Graph& G, Array<edge>& edges) {
2092  edges.init(G.numberOfEdges());
2093  int i = 0;
2094  for (edge v : G.edges) {
2095  edges[i++] = v;
2096  }
2097 }
2098 
2099 }
2100 
2101 struct NodePair {
2102  node source = nullptr;
2103  node target = nullptr;
2104  NodePair() = default;
2105 
2106  NodePair(node src, node tgt) : source(src), target(tgt) { }
2107 };
2108 
2109 inline std::ostream& operator<<(std::ostream& os, const NodePair& np) {
2110  os << "(" << np.source << "," << np.target << ")";
2111  return os;
2112 }
2113 
2114 }
2115 
ogdf::internal::EdgeArrayBase1::operator()
Value & operator()(adjEntry adj)
Returns a reference to the element associated with the edge corresponding to adj.
Definition: Graph_d.h:700
OGDF_COPY_CONSTR
#define OGDF_COPY_CONSTR(cls)
Declares the copy constructor for class cls.
Definition: copy_move.h:57
ogdf::RegistryBase
Abstract base class for registries.
Definition: RegisteredArray.h:95
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::RegisteredArray
Dynamic arrays indexed with arbitrary keys.
Definition: RegisteredArray.h:808
OGDF_DECL_REG_ARRAY
#define OGDF_DECL_REG_ARRAY(NAME)
Definition: RegisteredArray.h:960
ogdf::internal::GraphList< GraphObject >::size
int size() const
Returns the size of the list.
Definition: GraphList.h:84
ogdf::Graph::m_hiddenEdgeSets
List< HiddenEdgeSet * > m_hiddenEdgeSets
The list of hidden edges.
Definition: Graph_d.h:876
ogdf::Direction
Direction
Definition: basic.h:148
ogdf::Graph::empty
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
Definition: Graph_d.h:971
ogdf::Graph::CCsInfo::numberOfEdges
int numberOfEdges(int cc) const
Returns the number of edges in connected component cc.
Definition: Graph_d.h:1926
ogdf::Graph::adjEntryRegistry
internal::GraphAdjRegistry & adjEntryRegistry()
Returns a reference to the registry of adjEntry arrays associated with this graph.
Definition: Graph_d.h:1633
ogdf::Graph::sort
void sort(node v, const ADJ_ENTRY_LIST &newOrder)
Sorts the adjacency list of node v according to newOrder.
Definition: Graph_d.h:1474
ogdf::Graph::insert
std::pair< int, int > insert(const Graph &G)
Inserts a copy of a given Graph G into this graph.
Definition: Graph_d.h:1838
ogdf::Graph::pureNewNode
node pureNewNode(int index)
Creates a new node object with id index and adds it to the list of nodes.
Definition: Graph_d.h:1963
ogdf::GraphObserver::getGraph
const Graph * getGraph() const
Definition: Graph_d.h:796
ogdf::Graph::CCsInfo
Info structure for maintaining connected components.
Definition: Graph_d.h:1900
ogdf::AdjElement::pred
adjEntry pred() const
Returns the predecessor in the adjacency list.
Definition: Graph_d.h:214
ogdf::Graph::pureNewEdge
edge pureNewEdge(node src, node tgt, int index)
Creates a new edge object with id index and corresponding AdjElements and adds it to the list of edge...
Definition: Graph_d.h:1994
ogdf::internal::GraphRegisteredArray::graphOf
Graph * graphOf() const
Returns a pointer to the associated graph.
Definition: Graph_d.h:658
ogdf::GraphAdjIterator::m_pGraph
Graph * m_pGraph
Definition: Graph_d.h:517
ogdf::internal::GraphList< GraphObject >::tail
GraphObject * tail() const
Returns the last element in the list.
Definition: GraphList.h:322
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::Graph::insertAdjEntry
static void insertAdjEntry(node n, adjEntry newAdj, Direction dir)
Definition: Graph_d.h:2035
ogdf::GraphAdjIterator::operator!=
bool operator!=(const GraphAdjIterator &iter) const
Inequality operator.
Definition: Graph_d.h:551
ogdf::internal::GraphIteratorBase
Definition: graph_iterators.h:44
ogdf::Graph::CCsInfo::nodes
internal::SimpleRange< Array< node >::const_iterator > nodes(int cc) const
Definition: Graph_d.h:1934
ogdf::Graph::edgeRegistry
internal::GraphEdgeRegistry & edgeRegistry()
Returns a reference to the registry of edge arrays associated with this graph.
Definition: Graph_d.h:1625
ogdf::Graph::CCsInfo::e
edge e(int i) const
Returns the edge with index i.
Definition: Graph_d.h:1952
ogdf::AdjElement::theNode
node theNode() const
Returns the node whose adjacency list contains this element.
Definition: Graph_d.h:159
ogdf::NodeElement::m_indeg
int m_indeg
The indegree of the node.
Definition: Graph_d.h:238
ogdf::Graph::maxEdgeIndex
int maxEdgeIndex() const
Returns the largest used edge index.
Definition: Graph_d.h:983
ogdf::EdgeElement::isParallelUndirected
bool isParallelUndirected(edge e) const
Returns true iff edge e is parallel to this (undirected) edge (or if it is the same edge)
Definition: Graph_d.h:421
ogdf::Graph::CCsInfo::stopEdge
int stopEdge(int cc) const
Returns the index of (one past) the last edge in connected component cc.
Definition: Graph_d.h:1946
ogdf::internal::getAllEdges
void getAllEdges(const Graph &G, CONTAINER &edges)
Definition: Graph_d.h:2083
ogdf::Graph::HiddenEdgeSet::HiddenEdgeSet
HiddenEdgeSet(Graph &graph)
Creates a new set of hidden edges.
Definition: Graph_d.h:1226
ogdf::internal::GraphRegistry::GraphRegistry
GraphRegistry(Graph *graph, int *nextKeyIndex)
Constructor.
Definition: Graph_d.h:599
ogdf::AdjElement::counterClockwiseFaceSucc
adjEntry counterClockwiseFaceSucc() const
Returns the counter-clockwise successor in face.
Definition: Graph_d.h:198
ogdf::Graph::EdgeType
EdgeType
The type of edges (only used in derived classes).
Definition: Graph_d.h:901
ogdf::RegisteredArray::RA
typename std::conditional< WithDefault, internal::RegisteredArrayWithDefault< Registry, Value >, internal::RegisteredArrayWithoutDefault< Registry, Value > >::type RA
Definition: RegisteredArray.h:813
ogdf::Graph::swapAdjEdges
void swapAdjEdges(adjEntry adj1, adjEntry adj2)
Exchanges two entries in an adjacency list.
Definition: Graph_d.h:1571
ogdf::begin
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
ogdf::Graph::CCsInfo::m_startNode
Array< int > m_startNode
start node of each connected component in m_nodes.
Definition: Graph_d.h:1906
ogdf::NodeElement::lastAdj
adjEntry lastAdj() const
Returns the last entry in the adjacency list.
Definition: Graph_d.h:282
ogdf::Graph::HiddenEdgeSet
Functionality for temporarily hiding edges in constant time.
Definition: Graph_d.h:1216
ogdf::NodeElement::index
int index() const
Returns the (unique) node index.
Definition: Graph_d.h:267
ogdf::Graph::CCsInfo::constGraph
const Graph & constGraph() const
Returns the associated graph.
Definition: Graph_d.h:1917
ogdf::internal::getAllNodes
void getAllNodes(const Graph &G, CONTAINER &nodes)
Definition: Graph_d.h:2066
ogdf::internal::GraphElement::m_next
GraphElement * m_next
The successor in the list.
Definition: GraphList.h:60
ogdf::AdjElement::cyclicPred
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
Definition: Graph_d.h:351
ogdf::NodePair
Definition: Graph_d.h:2101
ogdf::internal::GraphElement
The base class for objects used by (hyper)graphs.
Definition: GraphList.h:55
ogdf::EdgeArray
internal::EdgeArrayBase2< Value, WithDefault > EdgeArray
RegisteredArray for labeling the edges in a Graph with an arbitrary Value.
Definition: Graph_d.h:738
ogdf::Graph::adjEntryRegistry
const internal::GraphAdjRegistry & adjEntryRegistry() const
Returns a const reference to the registry of adjEntry arrays associated with this graph.
Definition: Graph_d.h:1636
ogdf::Graph::moveAdjBefore
void moveAdjBefore(adjEntry adjMove, adjEntry adjBefore)
Moves adjacency entry adjMove before adjBefore.
Definition: Graph_d.h:1553
ogdf::Graph::allNodes
void allNodes(CONTAINER &nodeContainer) const
Returns a container with all nodes of the graph.
Definition: Graph_d.h:1028
Observer.h
Simple, safe base classes for C++ observables and observers.
ogdf::EdgeElement::isParallelDirected
bool isParallelDirected(edge e) const
Returns true iff edge e is parallel to this (directed) edge (or if it is the same edge)
Definition: Graph_d.h:418
ogdf::operator==
bool operator==(const Tuple2< E1, E2 > &t1, const Tuple2< E1, E2 > &t2)
Equality operator for 2-tuples.
Definition: tuples.h:74
ogdf::sync_plan::split
std::pair< node, node > split(Graph &G, sync_plan::PipeBij &bij, const EdgeArray< edge > *new_edges=nullptr, const EdgeArray< bool > *reverse_edges=nullptr, node src=nullptr, node tgt=nullptr)
ogdf::Graph::moveAdjAfter
void moveAdjAfter(adjEntry adjMove, adjEntry adjAfter)
Moves adjacency entry adjMove after adjAfter.
Definition: Graph_d.h:1538
ogdf::Graph::m_regEdgeArrays
internal::GraphEdgeRegistry m_regEdgeArrays
The registered edge arrays.
Definition: Graph_d.h:873
ogdf::GraphAdjIterator::operator--
GraphAdjIterator operator--(int)
Decrement operator (postfix).
Definition: Graph_d.h:573
ogdf::EdgeElement::isInvertedDirected
bool isInvertedDirected(edge e) const
Returns true iff edge e is an inverted edge to this (directed) edge.
Definition: Graph_d.h:415
ogdf::internal::GraphRegistry::graphOf
Graph * graphOf() const
Returns a pointer to the associated graph.
Definition: Graph_d.h:627
ogdf::Graph::nodeRegistry
const internal::GraphNodeRegistry & nodeRegistry() const
Returns a const reference to the registry of node arrays associated with this graph.
Definition: Graph_d.h:1620
ogdf::EdgeElement::index
int index() const
Returns the index of the edge.
Definition: Graph_d.h:388
ogdf::NodePair::source
node source
Definition: Graph_d.h:2102
ogdf::GraphAdjIterator
Iterator for AdjEntries of a graph.
Definition: Graph_d.h:516
ogdf::Graph::CCsInfo::m_startEdge
Array< int > m_startEdge
start edge of each connected component in m_edges.
Definition: Graph_d.h:1907
ogdf::filter_any_edge
bool filter_any_edge(edge e)
std::function<bool(edge)> that returns true for any edge e
ogdf::NodeElement::inEdges
void inEdges(EDGELIST &edgeList) const
Returns a list with all incoming edges of this node.
Definition: Graph_d.h:494
ogdf::Graph::insert
std::pair< int, int > insert(const Graph &G, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap)
Inserts a copy of a given Graph G into this graph.
Definition: Graph_d.h:1814
OGDF_CHECK_CONCEPT
#define OGDF_CHECK_CONCEPT(...)
Definition: Graph_d.h:127
ogdf::Graph::sort
void sort(node v, IT begin, IT end)
Sorts the adjacency list of node v according to the range denoted by two iterators.
Definition: Graph_d.h:1490
OGDF_AUGMENT_STATICCOMPARER
#define OGDF_AUGMENT_STATICCOMPARER(type)
Add this macro to your class to turn it into a full static comparer.
Definition: comparer.h:225
ogdf::BucketSourceIndex::getBucket
int getBucket(const edge &e) override
Returns source index of e.
Definition: Graph_d.h:2053
ogdf::BucketFunc
Abstract base class for bucket functions.
Definition: basic.h:255
ogdf::NodeElement::pred
node pred() const
Returns the predecessor in the list of all nodes.
Definition: Graph_d.h:288
ogdf::EdgeElement::m_src
node m_src
The source node of the edge.
Definition: Graph_d.h:360
OGDF_EDGE_ITER
#define OGDF_EDGE_ITER
Definition: Graph_d.h:123
OGDF_NO_MOVE
#define OGDF_NO_MOVE(cls)
Explicitly disables (deletes) move construction and assignment for class cls.
Definition: copy_move.h:42
ogdf::internal::EdgeArrayBase2< edge, WithDefault >::mapEndpoint
adjEntry mapEndpoint(adjEntry adj) const
Map a source/target adjEntry to the source/target adjEntry of the corresponding edges.
Definition: Graph_d.h:722
ogdf::Graph::CCsInfo::m_numCC
int m_numCC
the number of connected components.
Definition: Graph_d.h:1902
ogdf::internal::GraphObjectContainer
Public read-only interface for lists of graph objects.
Definition: GraphList.h:405
ogdf::AdjElement::graphOf
const Graph * graphOf() const
Definition: Graph_d.h:469
ogdf::GraphAdjIterator::operator++
GraphAdjIterator operator++(int)
Increment operator (postfix).
Definition: Graph_d.h:560
ogdf::Graph::postInsert
virtual void postInsert(void *userData, int newNodes, int newEdges)
Callback notifying subclasses that an insert() call has finished.
Definition: Graph_d.h:1895
ogdf::Array::init
void init()
Reinitializes the array to an array with empty index set.
Definition: Array.h:367
ogdf::Graph::allEdges
void allEdges(CONTAINER &edgeContainer) const
Returns a container with all edges of the graph.
Definition: Graph_d.h:1038
ogdf::AdjElement::twin
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
Definition: Graph_d.h:165
ogdf::NodeArray
internal::GraphRegisteredArray< NodeElement, Value, WithDefault > NodeArray
RegisteredArray for labeling the nodes in a Graph with an arbitrary Value.
Definition: Graph_d.h:733
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:84
ogdf::internal::GraphList::move
void move(T *pX, GraphList< T > &L, T *pY, Direction dir)
Moves element pX to list L and inserts it before or after pY.
Definition: GraphList.h:334
ogdf::Graph::HiddenEdgeSet::m_it
ListIterator< HiddenEdgeSet * > m_it
Definition: Graph_d.h:1278
ogdf::GraphAdjIterator::end
GraphAdjIterator end()
Returns an iterator to the one-past-last adjEntry in the associated graph.
Definition: Graph_d.h:531
ogdf::Graph::edgeRegistry
const internal::GraphEdgeRegistry & edgeRegistry() const
Returns a const reference to the registry of edge arrays associated with this graph.
Definition: Graph_d.h:1628
ogdf::AdjElement::m_edge
edge m_edge
The associated edge.
Definition: Graph_d.h:141
ogdf::EdgeElement::EdgeElement
EdgeElement(node src, node tgt, int id)
Constructs an edge element (src,tgt).
Definition: Graph_d.h:383
OGDF_NODE_FILTER
#define OGDF_NODE_FILTER
Definition: Graph_d.h:120
ogdf::Graph::CCsInfo::edges
internal::SimpleRange< Array< edge >::const_iterator > edges(int cc) const
Definition: Graph_d.h:1938
ogdf::Graph::nodeInserted
virtual void nodeInserted(void *userData, node original, node copy)
Callback notifying subclasses that insert() copied a node.
Definition: Graph_d.h:1877
ogdf::NodeElement::m_outdeg
int m_outdeg
The outdegree of the node.
Definition: Graph_d.h:239
ogdf::Graph::insert
std::pair< int, int > insert(const CCsInfo &info, int cc, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap)
Inserts a copy of a given connected component cc into this graph.
Definition: Graph_d.h:1794
ogdf::adjEntry
AdjElement * adjEntry
The type of adjacency entries.
Definition: Graph_d.h:71
ogdf::Graph::CCsInfo::v
node v(int i) const
Returns the node with index i.
Definition: Graph_d.h:1949
ogdf::filter_any_node
bool filter_any_node(node n)
std::function<bool(node)> that returns true for any node n
ogdf::AdjElement::faceCyclePred
adjEntry faceCyclePred() const
Returns the cyclic predecessor in face.
Definition: Graph_d.h:208
ogdf::internal::GraphRegistry::keyToIndex
static int keyToIndex(Key *key)
Definition: Graph_d.h:602
ogdf::Graph::CCsInfo::CCsInfo
CCsInfo()
Creates a info structure associated with no graph.
Definition: Graph_d.h:1911
ogdf::Graph::insertAdjEntry
static void insertAdjEntry(adjEntry oldAdj, adjEntry newAdj, Direction dir)
Definition: Graph_d.h:2027
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::NodeElement::m_pGraph
const Graph * m_pGraph
The graph containg this node (debug only).
Definition: Graph_d.h:244
InducedSubgraph.h
Implementation of the ogdf::Graph::insert(...) template methods.
ogdf::AdjElement::isSource
bool isSource() const
Returns true iff this is the source adjacency entry of the corresponding edge.
Definition: Graph_d.h:472
ogdf::Graph::newEdge
edge newEdge(adjEntry adjSrc, node w, int index=-1)
Creates a new edge at predefined positions in the adjacency lists.
Definition: Graph_d.h:1113
ogdf::NodeElement::compare
static int compare(const NodeElement &x, const NodeElement &y)
Standard Comparer.
Definition: Graph_d.h:341
ogdf::Graph::nodeRegistry
internal::GraphNodeRegistry & nodeRegistry()
Returns a reference to the registry of node arrays associated with this graph.
Definition: Graph_d.h:1617
ogdf::AdjElement::clockwiseFacePred
adjEntry clockwiseFacePred() const
Returns the clockwise predecessor in face. Use faceCycleSucc instead!
Definition: Graph_d.h:195
ogdf::edge
EdgeElement * edge
The type of edges.
Definition: Graph_d.h:67
Minisat::Internal::sort
void sort(T *array, int size, LessThan lt)
Definition: Sort.h:57
ogdf::internal::GraphRegistry::m_pGraph
Graph * m_pGraph
Definition: Graph_d.h:592
ogdf::AdjElement::theEdge
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:153
ogdf::Observable
Base class for an observable object that can be tracked by multiple Observer objects.
Definition: Observer.h:104
OGDF_NODE_ITER
#define OGDF_NODE_ITER
Definition: Graph_d.h:122
ogdf::EdgeElement::m_adjTgt
AdjElement * m_adjTgt
Corresponding adjacency entry at target node.
Definition: Graph_d.h:363
ogdf::Direction::after
@ after
ogdf::GraphAdjIterator::operator--
GraphAdjIterator & operator--()
Decrement operator (prefix).
Definition: Graph_d.h:567
ogdf::Graph::nodes
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:924
Minisat::Internal::copy
static void copy(const T &from, T &to)
Definition: Alg.h:61
ogdf::EdgeElement::isSelfLoop
bool isSelfLoop() const
Returns true iff the edge is a self-loop (source node = target node).
Definition: Graph_d.h:412
ogdf::Graph::reverseAdjEdges
void reverseAdjEdges(node v)
Reverses the adjacency list of v.
Definition: Graph_d.h:1512
ogdf::Graph::numberOfEdges
int numberOfEdges() const
Returns the number of edges in the graph.
Definition: Graph_d.h:977
ogdf::NodeElement::outdeg
int outdeg() const
Returns the outdegree of the node.
Definition: Graph_d.h:273
ogdf::BucketTargetIndex::getBucket
int getBucket(const edge &e) override
Returns target index of e.
Definition: Graph_d.h:2060
ogdf::NodeElement::degree
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:276
ogdf::AdjElement::clockwiseFaceSucc
adjEntry clockwiseFaceSucc() const
Returns the clockwise successor in face. Use faceCycleSucc instead!
Definition: Graph_d.h:192
ogdf::Graph::m_edgeIdCount
int m_edgeIdCount
The Index that will be assigned to the next created edge.
Definition: Graph_d.h:870
OGDF_MALLOC_NEW_DELETE
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition: memory.h:91
ogdf::internal::adjToNode
node adjToNode(adjEntry adj)
Definition: Graph_d.h:805
ogdf::Graph::CCsInfo::stopNode
int stopNode(int cc) const
Returns the index of (one past) the last node in connected component cc.
Definition: Graph_d.h:1932
ogdf::Graph::numberOfNodes
int numberOfNodes() const
Returns the number of nodes in the graph.
Definition: Graph_d.h:974
ogdf::AdjElement::AdjElement
AdjElement(node v)
Constructs an adjacency element for a given node.
Definition: Graph_d.h:146
ogdf::gml::Key::Graph
@ Graph
ogdf::AdjEntryArray
internal::GraphRegisteredArray< AdjElement, Value, WithDefault, internal::GraphAdjRegistry > AdjEntryArray
RegisteredArray for labeling the adjEntries in a Graph with an arbitrary Value.
Definition: Graph_d.h:744
backward::details::move
const T & move(const T &v)
Definition: backward.hpp:243
ogdf::Array< node >
GraphList.h
Decralation of GraphElement and GraphList classes.
ogdf::AdjElement::succ
adjEntry succ() const
Returns the successor in the adjacency list.
Definition: Graph_d.h:211
ogdf::NodeElement::adjEntries
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Definition: Graph_d.h:264
OGDF_EDGE_FILTER
#define OGDF_EDGE_FILTER
Definition: Graph_d.h:121
ogdf::calculateTableSize
int calculateTableSize(int actualCount)
The default growth function for registered arrays.
Definition: RegisteredArray.h:58
ogdf::internal::EA
EdgeArray< T, true > EA
Definition: GraphMultiArray.h:42
ogdf::internal::GraphList< GraphObject >::pushBack
void pushBack(GraphObject *pX)
Adds element pX at the end of the list.
Definition: GraphList.h:325
ogdf::NodeElement::indeg
int indeg() const
Returns the indegree of the node.
Definition: Graph_d.h:270
RegisteredArray.h
Declaration and implementation of RegisteredArray class.
ogdf::Graph::newEdge
edge newEdge(S src, Direction dirSrc, T tgt, Direction dirTgt, int index=-1)
Creates a new edge at predefined positions in the adjacency lists.
Definition: Graph_d.h:1160
ogdf::BucketSourceIndex
Bucket function using the index of an edge's source node as bucket.
Definition: Graph_d.h:2050
ogdf::EdgeSet
Edge sets.
Definition: Graph_d.h:748
ogdf::Graph::HiddenEdgeSet::m_edges
internal::GraphList< EdgeElement > m_edges
Definition: Graph_d.h:1277
ogdf::NodePair::target
node target
Definition: Graph_d.h:2103
ogdf::Graph::firstNode
node firstNode() const
Returns the first node in the list of all nodes.
Definition: Graph_d.h:989
ogdf::Graph::HiddenEdgeSet::~HiddenEdgeSet
~HiddenEdgeSet()
Restores all hidden edges.
Definition: Graph_d.h:1233
OGDF_NO_COPY
#define OGDF_NO_COPY(cls)
Explicitly disables (deletes) copy construction and assignment for class cls.
Definition: copy_move.h:37
ogdf::AdjElement::isBetween
bool isBetween(adjEntry adjBefore, adjEntry adjAfter) const
Returns whether this adjacency entry lies between adjBefore and adjAfter in clockwise rotation.
Definition: Graph_d.h:474
ogdf::internal::GraphRegistry::isKeyAssociated
bool isKeyAssociated(Key *key) const
Definition: Graph_d.h:604
ogdf::Graph::maxNodeIndex
int maxNodeIndex() const
Returns the largest used node index.
Definition: Graph_d.h:980
ogdf::EdgeElement::pred
edge pred() const
Returns the predecessor in the list of all edges.
Definition: Graph_d.h:429
ogdf::internal::GraphRegistry::m_nextKeyIndex
int * m_nextKeyIndex
Definition: Graph_d.h:593
ogdf::operator<<
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:978
ogdf::BucketTargetIndex
Bucket function using the index of an edge's target node as bucket.
Definition: Graph_d.h:2057
ogdf::Array::begin
iterator begin()
Returns an iterator to the first element.
Definition: Array.h:324
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:391
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63
ogdf::GraphObserver
Abstract Base class for graph observers.
Definition: Graph_d.h:770
ogdf::GraphObserver::GraphObserver
GraphObserver(const Graph *G)
Constructs instance of GraphObserver class.
Definition: Graph_d.h:779
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: List.h:42
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::RegistryBase::keyAdded
void keyAdded(Key key)
Records the addition of a new key and resizes all registered arrays if necessary.
Definition: RegisteredArray.h:162
ogdf::EdgeElement::adjSource
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
Definition: Graph_d.h:400
ogdf::internal::GraphListBase
Base class for GraphElement lists.
Definition: GraphList.h:67
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::internal::EdgeArrayBase1::operator[]
const Value & operator[](adjEntry adj) const
Returns a const reference to the element associated with the edge corresponding to adj.
Definition: Graph_d.h:679
ogdf::NodePair::NodePair
NodePair()=default
ogdf::internal::GraphList
Lists of graph objects (like nodes, edges, etc.).
Definition: GraphList.h:296
ogdf::Graph::preInsert
virtual void * preInsert(bool copyEmbedding, bool copyIDs, bool notifyObservers, bool edgeFilter, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap, int *newNodes, int *newEdges)
Callback notifying subclasses that some graph is about to be insert() -ed.
Definition: Graph_d.h:1865
ogdf::Graph::CCsInfo::numberOfNodes
int numberOfNodes(int cc) const
Returns the number of nodes in connected component cc.
Definition: Graph_d.h:1923
ogdf::Graph::lastNode
node lastNode() const
Returns the last node in the list of all nodes.
Definition: Graph_d.h:992
ogdf::AdjElement::m_id
int m_id
The (unique) index of the adjacency entry.
Definition: Graph_d.h:143
ogdf::Graph::NodeType
NodeType
The type of nodes.
Definition: Graph_d.h:904
OGDF_COPY_OP
#define OGDF_COPY_OP(cls)
Declares the copy assignment operation for class cls. Don't forget to return *this;.
Definition: copy_move.h:59
ogdf::Graph::lastEdge
edge lastEdge() const
Returns the last edge in the list of all edges.
Definition: Graph_d.h:998
ogdf::AdjElement::twinNode
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Definition: Graph_d.h:168
graph_iterators.h
Decralation of graph iterators.
ogdf::EdgeElement::getAdj
adjEntry getAdj(node v) const
Returns an adjacency entry of this edge at node v. If this is a self-loop the source adjacency entry ...
Definition: Graph_d.h:451
ogdf::AdjElement::cyclicSucc
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Definition: Graph_d.h:347
ogdf::AdjElement::m_twin
AdjElement * m_twin
The corresponding adjacency entry (same edge)
Definition: Graph_d.h:140
ogdf::internal::GraphList< GraphObject >::empty
bool empty() const
Returns true iff the list is empty.
Definition: GraphList.h:87
ogdf::Graph::m_nodeIdCount
int m_nodeIdCount
The Index that will be assigned to the next created node.
Definition: Graph_d.h:869
ogdf::EdgeElement::adjTarget
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
Definition: Graph_d.h:403
ogdf::GraphAdjIterator::m_entry
adjEntry m_entry
Definition: Graph_d.h:518
ogdf::EdgeElement::m_adjSrc
AdjElement * m_adjSrc
Corresponding adjacency entry at source node.
Definition: Graph_d.h:362
ogdf::Graph::representsCombEmbedding
bool representsCombEmbedding() const
Returns true iff the graph represents a combinatorial embedding.
Definition: Graph_d.h:1601
ogdf::NodeElement::allAdjEntries
void allAdjEntries(ADJLIST &adjList) const
Returns a list with all adjacency entries of this node.
Definition: Graph_d.h:296
ogdf::NodePair::NodePair
NodePair(node src, node tgt)
Definition: Graph_d.h:2106
ogdf::NodeElement::adjEdges
void adjEdges(EDGELIST &edgeList) const
Returns a list with all edges incident to this node.
Definition: Graph_d.h:312
ogdf::Graph::newEdge
edge newEdge(adjEntry adjSrc, adjEntry adjTgt, Direction dir=Direction::after, int index=-1)
Creates a new edge at predefined positions in the adjacency lists.
Definition: Graph_d.h:1135
ogdf::internal::GraphList< GraphObject >::head
GraphObject * head() const
Returns the first element in the list.
Definition: GraphList.h:319
ogdf::Observer
Base class for an observer for a single Observable object.
Definition: Observer.h:53
ogdf::Graph::firstEdge
edge firstEdge() const
Returns the first edge in the list of all edges.
Definition: Graph_d.h:995
ogdf::Graph::edges
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:927
ogdf::internal::GraphElement::m_prev
GraphElement * m_prev
The predecessor in the list.
Definition: GraphList.h:61
ogdf::GraphAdjIterator::operator==
bool operator==(const GraphAdjIterator &iter) const
Equality operator.
Definition: Graph_d.h:546
ogdf::AdjElement::compare
static int compare(const AdjElement &x, const AdjElement &y)
Standard Comparer.
Definition: Graph_d.h:226
OGDF_NODE_LIST
#define OGDF_NODE_LIST
Definition: Graph_d.h:124
ogdf::GraphAdjIterator::operator->
AdjElement & operator->() const
Returns a reference to the associated adjElement.
Definition: Graph_d.h:543
ogdf::end
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
ogdf::internal::SimpleRange
Definition: graph_iterators.h:206
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::Graph::HiddenEdgeSet::m_graph
Graph * m_graph
Definition: Graph_d.h:1279
ogdf::internal::EdgeArrayBase1
RegisteredArray for edges of a graph.
Definition: Graph_d.h:669
ogdf::EdgeElement::compare
static int compare(const EdgeElement &x, const EdgeElement &y)
Standard Comparer.
Definition: Graph_d.h:457
ogdf::Graph::newNode
node newNode(int index=-1)
Creates a new node and returns it.
Definition: Graph_d.h:1056
ogdf::NodeElement::firstAdj
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:279
ogdf::NodeElement::succ
node succ() const
Returns the successor in the list of all nodes.
Definition: Graph_d.h:285
ogdf::AdjElement::faceCycleSucc
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
Definition: Graph_d.h:205
ogdf::EdgeElement::m_tgt
node m_tgt
The target node of the edge.
Definition: Graph_d.h:361
ogdf::Graph::m_regNodeArrays
internal::GraphNodeRegistry m_regNodeArrays
The registered node arrays.
Definition: Graph_d.h:872
ogdf::EdgeElement::opposite
node opposite(node v) const
Returns the adjacent node different from v.
Definition: Graph_d.h:406
ogdf::Graph::CCsInfo::startNode
int startNode(int cc) const
Returns the index of the first node in connected component cc.
Definition: Graph_d.h:1929
OGDF_EDGE_LIST
#define OGDF_EDGE_LIST
Definition: Graph_d.h:125
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::internal::EdgeArrayBase1::operator[]
Value & operator[](adjEntry adj)
Returns a reference to the element associated with the edge corresponding to adj.
Definition: Graph_d.h:686
ogdf::Graph::moveAdj
void moveAdj(adjEntry adjMove, Direction dir, adjEntry adjPos)
Moves adjacency entry adjMove before or after adjPos.
Definition: Graph_d.h:1522
ogdf::Graph::CCsInfo::m_graph
const Graph * m_graph
points to the associated graph.
Definition: Graph_d.h:1901
ogdf::EdgeElement::succ
edge succ() const
Returns the successor in the list of all edges.
Definition: Graph_d.h:426
ogdf::NodeElement::graphOf
const Graph * graphOf() const
Returns the graph containing this node (debug only).
Definition: Graph_d.h:337
ogdf::Graph::CCsInfo::m_nodes
Array< node > m_nodes
array of all nodes.
Definition: Graph_d.h:1904
ogdf::Graph::CCsInfo::m_edges
Array< edge > m_edges
array of all edges.
Definition: Graph_d.h:1905
ogdf::AdjElement::AdjElement
AdjElement(edge e, int id)
Constructs an adjacency entry for a given edge and index.
Definition: Graph_d.h:149
ogdf::RegisteredArray< GraphRegistry< Key >, Value, WithDefault, Graph >::init
void init(const Graph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
Definition: RegisteredArray.h:849
ogdf::EdgeElement::isIncident
bool isIncident(node v) const
Returns true iff v is incident to the edge.
Definition: Graph_d.h:437
ogdf::AdjElement::m_node
node m_node
The node whose adjacency list contains this entry.
Definition: Graph_d.h:142
ogdf::Graph::newEdge
edge newEdge(node v, adjEntry adjTgt, int index=-1)
Creates a new edge at predefined positions in the adjacency lists.
Definition: Graph_d.h:1094
ogdf::Graph::maxAdjEntryIndex
int maxAdjEntryIndex() const
Returns the largest used adjEntry index.
Definition: Graph_d.h:986
ogdf::AdjElement::counterClockwiseFacePred
adjEntry counterClockwiseFacePred() const
Returns the counter-clockwise predecessor in face.
Definition: Graph_d.h:201
ogdf::Graph::insert
std::pair< int, int > insert(const NL &nodeList, const EL &edgeList, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap)
Inserts a copy of a given subgraph into this graph.
Definition: Graph_d.h:1775
ogdf::EdgeElement::EdgeElement
EdgeElement(node src, node tgt, AdjElement *adjSrc, AdjElement *adjTgt, int id)
Constructs an edge element (src,tgt).
Definition: Graph_d.h:374
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:46
ogdf::AdjElement::index
int index() const
Returns the index of this adjacency element.
Definition: Graph_d.h:171
ogdf::internal::GraphRegistry::maxKeyIndex
int maxKeyIndex() const
Definition: Graph_d.h:624
ogdf::NodeElement::outEdges
void outEdges(EDGELIST &edgeList) const
Returns a list with all outgoing edges of this node.
Definition: Graph_d.h:505
ogdf::internal::GraphRegistry::iterator
typename Iterable::iterator iterator
Definition: Graph_d.h:596
ogdf::RegistryBase< Key *, GraphRegistry< Key, GraphObjectContainer< Key >, 1 >, GraphObjectContainer< Key > ::iterator >::getArraySize
int getArraySize() const
Returns the current size of all registered arrays.
Definition: RegisteredArray.h:236
ogdf::Graph::edgeInserted
virtual void edgeInserted(void *userData, edge original, edge copy)
Callback notifying subclasses that insert() copied an edge.
Definition: Graph_d.h:1886
ogdf::internal::EdgeArrayBase1::operator()
const Value & operator()(adjEntry adj) const
Returns a const reference to the element associated with the edge corresponding to adj.
Definition: Graph_d.h:693
ogdf::EdgeElement::nodes
std::array< node, 2 > nodes() const
Returns a list of adjacent nodes. If this edge is a self-loop, both entries will be the same node.
Definition: Graph_d.h:397
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:394
ogdf::Graph::CCsInfo::numberOfCCs
int numberOfCCs() const
Returns the number of connected components.
Definition: Graph_d.h:1920
ogdf::GraphAdjIterator::operator++
GraphAdjIterator & operator++()
Increment operator (prefix).
Definition: Graph_d.h:554
ogdf::NodeElement::m_id
int m_id
The (unique) index of the node.
Definition: Graph_d.h:240
ogdf::Graph::newEdge
edge newEdge(node v, node w, int index=-1)
Creates a new edge (v,w) and returns it.
Definition: Graph_d.h:1075
ogdf::EdgeElement::m_id
int m_id
Definition: Graph_d.h:364
ogdf::copyEmbedding
void copyEmbedding(const Graph &from, Graph &to, std::function< adjEntry(adjEntry)> adjMapFromTo)
ogdf::internal::GraphRegistry
Registry for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:590
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::Graph::m_regAdjArrays
internal::GraphAdjRegistry m_regAdjArrays
The registered adjEntry arrays.
Definition: Graph_d.h:874
ogdf::EdgeElement::commonNode
node commonNode(edge e) const
Returns the common node of the edge and e. Returns nullptr if the two edges are not adjacent.
Definition: Graph_d.h:443
ogdf::GraphAdjIterator::operator*
adjEntry operator*() const
Returns the associated adjEntry.
Definition: Graph_d.h:540
ogdf::EdgeElement::isAdjacent
bool isAdjacent(edge e) const
Returns true iff e is adjacent to the edge.
Definition: Graph_d.h:440
ogdf::internal::GraphRegistry::calculateArraySize
int calculateArraySize(int add) const
Definition: Graph_d.h:620
ogdf::Graph::CCsInfo::startEdge
int startEdge(int cc) const
Returns the index of the first edge in connected component cc.
Definition: Graph_d.h:1943
ogdf::Graph::collapse
void collapse(NODELIST &nodesToCollapse)
Collapses all nodes in the list nodesToCollapse to the first node in the list.
Definition: Graph_d.h:1444
ogdf::NodeElement::NodeElement
NodeElement(const Graph *pGraph, int id)
Constructs a node element with index id.
Definition: Graph_d.h:255
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709
ogdf::RegistryBase::reserveSpace
void reserveSpace(int new_keys)
Resizes all arrays to make space of new_keys new keys.
Definition: RegisteredArray.h:197