Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

Graph_d.h
Go to the documentation of this file.
1 
35 #pragma once
36 
37 #include <ogdf/basic/GraphList.h>
39 #include <mutex>
40 
41 #ifdef OGDF_DEBUG
42 # include <set>
43 #endif
44 
45 namespace ogdf {
46 
47 //
48 // in embedded graphs, adjacency lists are given in clockwise order.
49 //
50 
51 
52 class OGDF_EXPORT Graph;
53 class OGDF_EXPORT NodeElement;
54 class OGDF_EXPORT EdgeElement;
55 class OGDF_EXPORT AdjElement;
56 class OGDF_EXPORT FaceElement;
57 class OGDF_EXPORT ClusterElement;
58 
59 
62 using node = NodeElement*;
63 
66 using edge = EdgeElement*;
67 
71 
72 
74 
79  friend class Graph;
82 
86  int m_id;
87 
89  explicit AdjElement(node v) : m_node(v) { }
91  AdjElement(edge e, int id) : m_edge(e), m_id(id) { }
92 
93 public:
95  edge theEdge() const { return m_edge; }
97  operator edge() const { return m_edge; }
99  node theNode() const { return m_node; }
100 
102  adjEntry twin() const { return m_twin; }
103 
105  node twinNode() const { return m_twin->m_node; }
106 
108  int index() const { return m_id; }
109 
111  bool isSource() const;
112 
123  bool isBetween(adjEntry adjBefore, adjEntry adjAfter) const;
124 
125  // traversing faces in clockwise (resp. counter-clockwise) order
126  // (if face is an interior face)
127 
129  adjEntry clockwiseFaceSucc() const { return m_twin->cyclicPred(); }
131  adjEntry clockwiseFacePred() const { return cyclicSucc()->m_twin; }
133  adjEntry counterClockwiseFaceSucc() const { return m_twin->cyclicSucc(); }
135  adjEntry counterClockwiseFacePred() const { return cyclicPred()->m_twin; }
136 
137  // default is traversing faces in clockwise order
139  adjEntry faceCycleSucc() const { return clockwiseFaceSucc(); }
141  adjEntry faceCyclePred() const { return clockwiseFacePred(); }
142 
143 
145  adjEntry succ() const { return static_cast<adjEntry>(m_next); }
147  adjEntry pred() const { return static_cast<adjEntry>(m_prev); }
148 
150  adjEntry cyclicSucc() const;
152  adjEntry cyclicPred() const;
153 
154 #ifdef OGDF_DEBUG
155  const Graph *graphOf() const;
156 #endif
157 
159  static int compare(const AdjElement& x,const AdjElement& y) { return x.m_id-y.m_id; }
161 
163 }; // class AdjElement
164 
165 
168  friend class Graph;
170 
171  //GraphList<AdjElement> m_adjEdges; //!< The adjacency list of the node.
172  int m_indeg;
173  int m_outdeg;
174  int m_id;
175 
176 #ifdef OGDF_DEBUG
177  // we store the graph containing this node for debugging purposes
178  const Graph *m_pGraph;
179 #endif
180 
181 
183 #ifdef OGDF_DEBUG
184 
189  NodeElement(const Graph *pGraph, int id) :
190  m_indeg(0), m_outdeg(0), m_id(id), m_pGraph(pGraph) { }
191 #else
192  NodeElement(int id) : m_indeg(0), m_outdeg(0), m_id(id) { }
193 #endif
194 
195 
196 public:
199 
201  int index() const { return m_id; }
202 
204  int indeg() const { return m_indeg; }
206  int outdeg() const { return m_outdeg; }
208  int degree() const { return m_indeg + m_outdeg; }
209 
211  adjEntry firstAdj() const { return adjEntries.head(); }
213  adjEntry lastAdj () const { return adjEntries.tail(); }
214 
216  node succ() const { return static_cast<node>(m_next); }
218  node pred() const { return static_cast<node>(m_prev); }
219 
221 
225  template<class ADJLIST>
226  void allAdjEntries(ADJLIST &adjList) const {
227  adjList.clear();
228  for(adjEntry adj : this->adjEntries) {
229  adjList.pushBack(adj);
230  }
231  }
232 
234 
241  template<class EDGELIST>
242  void adjEdges(EDGELIST &edgeList) const {
243  edgeList.clear();
244  for(adjEntry adj : this->adjEntries) {
245  edgeList.pushBack(adj->theEdge());
246  }
247  }
248 
250 
254  template<class EDGELIST>
255  void inEdges(EDGELIST &edgeList) const;
256 
258 
262  template<class EDGELIST>
263  void outEdges(EDGELIST &edgeList) const;
264 
265 #ifdef OGDF_DEBUG
266  const Graph *graphOf() const { return m_pGraph; }
268 #endif
269 
271  static int compare(const NodeElement& x,const NodeElement& y) { return x.m_id-y.m_id; }
273 
275 }; // class NodeElement
276 
277 
279 {
280  return (m_next) ? static_cast<adjEntry>(m_next) : m_node->firstAdj();
281 }
282 
284 {
285  return (m_prev) ? static_cast<adjEntry>(m_prev) : m_node->lastAdj();
286 }
287 
288 
289 
292  friend class Graph;
294 
299  int m_id; // The (unique) index of the node.
300 
302 
309  EdgeElement(node src, node tgt, AdjElement *adjSrc, AdjElement *adjTgt, int id) :
310  m_src(src), m_tgt(tgt), m_adjSrc(adjSrc), m_adjTgt(adjTgt), m_id(id) { }
311 
313 
318  EdgeElement(node src, node tgt, int id) :
319  m_src(src), m_tgt(tgt), m_id(id) { }
320 
321 public:
323  int index() const { return m_id; }
325  node source() const { return m_src; }
327  node target() const { return m_tgt; }
328 
330  adjEntry adjSource() const { return m_adjSrc; }
332  adjEntry adjTarget() const { return m_adjTgt; }
333 
335  node opposite(node v) const { return (v == m_src) ? m_tgt : m_src; }
336  // Returns true iff the edge is a self-loop (source node = target node).
337  bool isSelfLoop() const { return m_src == m_tgt; }
338 
340  edge succ() const { return static_cast<edge>(m_next); }
342  edge pred() const { return static_cast<edge>(m_prev); }
343 
344 #ifdef OGDF_DEBUG
345  const Graph *graphOf() const { return m_src->graphOf(); }
347 #endif
348 
350  bool isIncident(node v) const { return v == m_src || v == m_tgt; }
351 
353  node commonNode(edge e) const { return (m_src==e->m_src || m_src==e->m_tgt) ? m_src : ((m_tgt==e->m_src || m_tgt==e->m_tgt) ? m_tgt: nullptr); }
354 
357  adjEntry getAdj(node v) const {
358  OGDF_ASSERT(this->isIncident(v));
359  return v == m_src ? m_adjSrc : m_adjTgt;
360  }
361 
363  static int compare(const EdgeElement& x,const EdgeElement& y) { return x.m_id-y.m_id; }
365 
367 
368 #ifdef OGDF_DEBUG
369 private:
370  bool m_hidden = false;
371 #endif
372 }; // class EdgeElement
373 
374 
375 #ifdef OGDF_DEBUG
376 inline const Graph *AdjElement::graphOf() const {
377  return m_node->graphOf();
378 }
379 #endif
380 
381 inline bool AdjElement::isSource() const {
382  return this == m_edge->adjSource();
383 }
384 
385 inline bool AdjElement::isBetween(adjEntry adjBefore, adjEntry adjAfter) const {
386 #ifdef OGDF_DEBUG
387  node v = this->theNode();
388  OGDF_ASSERT(adjBefore->theNode() == v);
389  OGDF_ASSERT(adjAfter->theNode() == v);
390 #endif
391  bool result = this != adjBefore && this != adjAfter && adjBefore != adjAfter;
392 
393  if (result) {
394  adjEntry adj = adjBefore;
395  for (; adj != this && adj != adjAfter; adj = adj->cyclicSucc());
396  result = adj == this;
397  }
398 
399  return result;
400 }
401 
402 template<class EDGELIST>
403 void NodeElement::inEdges(EDGELIST &edgeList) const {
404  edgeList.clear();
405  for(adjEntry adj : this->adjEntries) {
406  edge e = adj->theEdge();
407  if (adj == e->adjTarget()) edgeList.pushBack(e);
408  }
409 }
410 
411 template<class EDGELIST>
412 void NodeElement::outEdges(EDGELIST &edgeList) const {
413  edgeList.clear();
414  for(adjEntry adj : this->adjEntries) {
415  edge e = adj->theEdge();
416  if (adj == e->adjSource()) edgeList.pushBack(e);
417  }
418 }
419 
420 class NodeArrayBase;
421 class EdgeArrayBase;
422 class AdjEntryArrayBase;
423 template<class T> class NodeArray;
424 template<class T> class EdgeArray;
425 template<class T> class AdjEntryArray;
427 
429 
473 {
474 public:
476 private:
477  int m_nodeIdCount;
479 
482 
487 
488 #ifndef OGDF_MEMORY_POOL_NTS
489  mutable std::mutex m_mutexRegArrays;
490 #endif
491 
493 
494 public:
495 
502 
509 
511 
516 
518  enum class EdgeType {
519  association = 0,
520  generalization = 1,
521  dependency = 2
522  }; // should be more flexible, standard, dissect, expand
523 
525  enum class NodeType {
526  vertex = 0,
527  dummy = 1,
528  generalizationMerger = 2,
529  generalizationExpander = 3,
530  highDegreeExpander = 4,
531  lowDegreeExpander = 5,
532  associationClass = 6
533  };
534 
536 
537 
543 
546 
549 
551 
552 
554  Graph();
555 
557 
564  Graph(const Graph &G);
565 
567  virtual ~Graph();
568 
573 
575  bool empty() const { return nodes.empty(); }
576 
578  int numberOfNodes() const { return nodes.size(); }
579 
581  int numberOfEdges() const { return edges.size(); }
582 
584  int maxNodeIndex() const { return m_nodeIdCount-1; }
586  int maxEdgeIndex() const { return m_edgeIdCount-1; }
588  int maxAdjEntryIndex() const { return (m_edgeIdCount<<1)-1; }
589 
591  int nodeArrayTableSize() const { return m_nodeArrayTableSize; }
593  int edgeArrayTableSize() const { return m_edgeArrayTableSize; }
595  int adjEntryArrayTableSize() const { return m_edgeArrayTableSize << 1; }
596 
598  node firstNode() const { return nodes.head(); }
600  node lastNode () const { return nodes.tail(); }
601 
603  edge firstEdge() const { return edges.head(); }
605  edge lastEdge () const { return edges.tail(); }
606 
614  node chooseNode(std::function<bool(node)> includeNode = [](node) { return true; }, bool isFastTest = true) const;
615 
623  edge chooseEdge(std::function<bool(edge)> includeEdge = [](edge) { return true; }, bool isFastTest = true) const;
624 
626 
630  template<class NODELIST>
631  void allNodes(NODELIST &nodeList) const {
632  nodeList.clear();
633  for (node v = nodes.head(); v; v = v->succ())
634  nodeList.pushBack(v);
635  }
636 
638 
642  template<class EDGELIST>
643  void allEdges(EDGELIST &edgeList) const {
644  edgeList.clear();
645  for (edge e = edges.head(); e; e = e->succ())
646  edgeList.pushBack(e);
647  }
648 
649 
651 
655 
657  node newNode();
658 
660 
669  node newNode(int index);
670 
672 
677  edge newEdge(node v, node w);
678 
680 
691  edge newEdge(node v, node w, int index);
692 
694 
707  edge newEdge(adjEntry adjSrc, adjEntry adjTgt, Direction dir = Direction::after);
708 
710 
720  edge newEdge(node v, adjEntry adjTgt);
721 
723 
733  edge newEdge(adjEntry adjSrc, node w);
734 
735 
737 
741 
743  virtual void delNode(node v);
744 
746  virtual void delEdge(edge e);
747 
749  virtual void clear();
750 
771  {
772  friend class Graph;
773  friend class EdgeElement;
774 
775  public:
781  explicit HiddenEdgeSet(Graph &graph) : m_graph(&graph)
782  {
783  m_it = m_graph->m_hiddenEdgeSets.pushFront(this);
784  }
785 
790  {
791  if (m_graph) {
792  restore();
793  m_graph->m_hiddenEdgeSets.del(m_it);
794  }
795  }
796 
803  void hide(edge e);
804 
811  void restore(edge e);
812 
819  void restore();
820 
824  int size();
825 
826  private:
830 
831  // prevent copying
833  HiddenEdgeSet& operator=(const HiddenEdgeSet&);
834  };
835 
840 
842 
851  virtual edge split(edge e);
852 
854 
864  void unsplit(node u);
865 
867 
878  virtual void unsplit(edge eIn, edge eOut);
879 
881 
898  node splitNode(adjEntry adjStartLeft, adjEntry adjStartRight);
899 
901 
906  node contract(edge e);
907 
909 
923  void move(edge e, adjEntry adjSrc, Direction dirSrc,
924  adjEntry adjTgt, Direction dirTgt);
925 
927 
933  void moveTarget(edge e, node w);
934 
936 
944  void moveTarget(edge e, adjEntry adjTgt, Direction dir);
945 
947 
953  void moveSource(edge e, node w);
954 
956 
964  void moveSource(edge e, adjEntry adjSrc, Direction dir);
965 
967 
972  edge searchEdge (node v, node w) const;
973 
975  void reverseEdge(edge e);
976 
978  void reverseAllEdges();
979 
981 
987  template<class NODELIST>
988  void collapse(NODELIST &nodesToCollapse){
989  node v = nodesToCollapse.popFrontRet();
990  while (!nodesToCollapse.empty())
991  {
992  node w = nodesToCollapse.popFrontRet();
993  adjEntry adj = w->firstAdj();
994  while (adj != nullptr)
995  {
996  adjEntry succ = adj->succ();
997  edge e = adj->theEdge();
998  if (e->source() == v || e->target() == v)
999  delEdge(e);
1000  else if (e->source() == w)
1001  moveSource(e,v);
1002  else
1003  moveTarget(e,v);
1004  adj = succ;
1005  }
1006  delNode(w);
1007  }
1008  }
1009 
1011 
1018  template<class ADJ_ENTRY_LIST>
1019  void sort(node v, const ADJ_ENTRY_LIST &newOrder) {
1020 #ifdef OGDF_DEBUG
1021  std::set<int> entries;
1022  int counter = 0;
1023 
1024  for(adjEntry adj : newOrder) {
1025  entries.insert(adj->index());
1026  OGDF_ASSERT(adj->theNode() == v);
1027  counter++;
1028  }
1029 
1030  OGDF_ASSERT(counter == v->degree());
1031  OGDF_ASSERT(entries.size() == static_cast<unsigned int>(v->degree()));
1032 #endif
1033  v->adjEntries.sort(newOrder);
1034  }
1035 
1037 
1041  v->adjEntries.reverse();
1042  }
1043 
1045 
1052  void moveAdj(adjEntry adjMove, Direction dir, adjEntry adjPos) {
1053  OGDF_ASSERT(adjMove != nullptr);
1054  OGDF_ASSERT(adjPos != nullptr);
1055  OGDF_ASSERT(adjMove->graphOf() == this);
1056  OGDF_ASSERT(adjPos->graphOf() == this);
1057  internal::GraphList<AdjElement> &adjList = adjMove->m_node->adjEntries;
1058  adjList.move(adjMove, adjList, adjPos, dir);
1059  }
1060 
1062 
1068  void moveAdjAfter(adjEntry adjMove, adjEntry adjAfter) {
1069  OGDF_ASSERT(adjMove != nullptr);
1070  OGDF_ASSERT(adjAfter != nullptr);
1071  OGDF_ASSERT(adjMove->graphOf() == this);
1072  OGDF_ASSERT(adjAfter->graphOf() == this);
1073  adjMove->m_node->adjEntries.moveAfter(adjMove,adjAfter);
1074  }
1075 
1077 
1083  void moveAdjBefore(adjEntry adjMove, adjEntry adjBefore) {
1084  OGDF_ASSERT(adjMove != nullptr);
1085  OGDF_ASSERT(adjBefore != nullptr);
1086  OGDF_ASSERT(adjMove->graphOf() == this);
1087  OGDF_ASSERT(adjBefore->graphOf() == this);
1088  adjMove->m_node->adjEntries.moveBefore(adjMove,adjBefore);
1089  }
1090 
1092  void reverseAdjEdges();
1093 
1095 
1101  void swapAdjEdges(adjEntry adj1, adjEntry adj2) {
1102  OGDF_ASSERT(adj1->theNode() == adj2->theNode());
1103  OGDF_ASSERT(adj1->graphOf() == this);
1104 
1105  adj1->theNode()->adjEntries.swap(adj1,adj2);
1106  }
1107 
1108 
1110 
1114 
1116 
1126  int genus() const;
1127 
1129 
1133  return genus() == 0;
1134  }
1135 
1137 
1142  bool consistencyCheck() const;
1143 
1144 
1146 
1152 
1154 
1161  ListIterator<NodeArrayBase*> registerArray(NodeArrayBase *pNodeArray) const;
1162 
1164 
1171  ListIterator<EdgeArrayBase*> registerArray(EdgeArrayBase *pEdgeArray) const;
1172 
1174 
1182  ListIterator<AdjEntryArrayBase*> registerArray(AdjEntryArrayBase *pAdjArray) const;
1183 
1185 
1191  ListIterator<GraphObserver*> registerStructure(GraphObserver *pStructure) const;
1192 
1194 
1198  void unregisterArray(ListIterator<NodeArrayBase*> it) const;
1199 
1201 
1205  void unregisterArray(ListIterator<EdgeArrayBase*> it) const;
1206 
1208 
1212  void unregisterArray(ListIterator<AdjEntryArrayBase*> it) const;
1213 
1215 
1219  void unregisterStructure(ListIterator<GraphObserver*> it) const;
1220 
1222  void moveRegisterArray(ListIterator<NodeArrayBase*> it, NodeArrayBase *pNodeArray) const;
1223 
1225  void moveRegisterArray(ListIterator<EdgeArrayBase*> it, EdgeArrayBase *pEdgeArray) const;
1226 
1228  void moveRegisterArray(ListIterator<AdjEntryArrayBase*> it, AdjEntryArrayBase *pAdjArray) const;
1229 
1231 
1256  void resetEdgeIdCount(int maxId);
1257 
1258 
1260 
1264 
1273  Graph &operator=(const Graph &G);
1274 
1276 
1278 
1279 public:
1280 
1282  static int nextPower2(int start, int idCount);
1283 
1284 
1287 
1288  const Graph *m_graph;
1289  int m_numCC;
1290 
1295 
1296  public:
1298  CCsInfo() : m_graph(nullptr), m_numCC(0) { }
1299 
1301  explicit CCsInfo(const Graph& G);
1302 
1304  const Graph &constGraph() const { return *m_graph; }
1305 
1307  int numberOfCCs() const { return m_numCC; }
1308 
1310  int numberOfNodes(int cc) const { return stopNode(cc) - startNode(cc); }
1311 
1313  int numberOfEdges(int cc) const { return stopEdge(cc) - startEdge(cc); }
1314 
1316  int startNode(int cc) const { return m_startNode[cc]; }
1317 
1319  int stopNode (int cc) const { return m_startNode[cc+1]; }
1320 
1322  int startEdge(int cc) const { return m_startEdge[cc]; }
1323 
1325  int stopEdge (int cc) const { return m_startEdge[cc+1]; }
1326 
1328  node v(int i) const { return m_nodes[i]; }
1329 
1331  edge e(int i) const { return m_edges[i]; }
1332  };
1333 
1334 protected:
1335  void construct(const Graph &G, NodeArray<node> &mapNode, EdgeArray<edge> &mapEdge);
1336 
1337  void assign(const Graph &G, NodeArray<node> &mapNode, EdgeArray<edge> &mapEdge);
1338 
1340 
1344  void constructInitByNodes(
1345  const Graph &G,
1346  const List<node> &nodeList,
1347  NodeArray<node> &mapNode,
1348  EdgeArray<edge> &mapEdge);
1349 
1350  void constructInitByActiveNodes(
1351  const List<node> &nodeList,
1352  const NodeArray<bool> &activeNodes,
1353  NodeArray<node> &mapNode,
1354  EdgeArray<edge> &mapEdge);
1355 
1357  void constructInitByCC(
1358  const CCsInfo &info,
1359  int cc,
1360  NodeArray<node> &mapNode,
1361  EdgeArray<edge> &mapEdge);
1362 
1363 private:
1364  void copy(const Graph &G, NodeArray<node> &mapNode,
1365  EdgeArray<edge> &mapEdge);
1366  void copy(const Graph &G);
1367 
1368  edge createEdgeElement(node v, node w, adjEntry adjSrc, adjEntry adjTgt);
1369  node pureNewNode();
1370 
1371  // moves adjacency entry to node w
1372  void moveAdj(adjEntry adj, node w);
1373 
1374  void reinitArrays();
1375  void reinitStructures();
1376  void resetAdjEntryIndex(int newIndex, int oldIndex);
1377 
1381  void restoreAllEdges();
1382 
1383 }; // class Graph
1384 
1385 OGDF_EXPORT std::ostream & operator<<(std::ostream &os, const Graph::EdgeType &et);
1386 
1389 public:
1391  int getBucket(const edge &e) override { return e->source()->index(); }
1392 };
1393 
1396 public:
1398  int getBucket(const edge &e) override { return e->target()->index(); }
1399 };
1400 
1401 struct NodePair {
1402  node source = nullptr;
1403  node target = nullptr;
1404  NodePair() = default;
1405  NodePair(node src, node tgt) : source(src), target(tgt) {}
1406 };
1407 
1408 inline ostream &operator<<(ostream &os, const NodePair& np) {
1409  os << "(" << np.source << "," << np.target << ")";
1410  return os;
1411 }
1412 
1413 } //namespace
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:327
void adjEdges(EDGELIST &edgeList) const
Returns a list with all edges incident to this node.
Definition: Graph_d.h:242
int m_nodeIdCount
The Index that will be assigned to the next created node.
Definition: Graph_d.h:475
void moveAdjBefore(adjEntry adjMove, adjEntry adjBefore)
Moves adjacency entry adjMove before adjBefore.
Definition: Graph_d.h:1083
bool isSource() const
Returns true iff this is the source adjacency entry of the corresponding edge.
Definition: Graph_d.h:381
Abstract base class for node arrays.
Definition: NodeArray.h:45
node m_tgt
The target node of the edge.
Definition: Graph_d.h:296
EdgeElement * edge
The type of edges.
Definition: Graph_d.h:66
Array< int > m_startEdge
start edge of each connected component in m_edges.
Definition: Graph_d.h:1294
Functionality for temporarily hiding edges in constant time.
Definition: Graph_d.h:770
int numberOfEdges(int cc) const
Returns the number of edges in connected component cc.
Definition: Graph_d.h:1313
adjEntry pred() const
Returns the predecessor in the adjacency list.
Definition: Graph_d.h:147
HiddenEdgeSet(Graph &graph)
Creates a new set of hidden edges.
Definition: Graph_d.h:781
node pred() const
Returns the predecessor in the list of all nodes.
Definition: Graph_d.h:218
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:95
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
edge m_edge
The associated edge.
Definition: Graph_d.h:84
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
static int compare(const AdjElement &x, const AdjElement &y)
Standard Comparer.
Definition: Graph_d.h:159
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
Definition: Graph_d.h:330
AdjElement(node v)
Constructs an adjacency element for a given node.
Definition: Graph_d.h:89
static const int Graph
Definition: GmlParser.h:59
void sort(node v, const ADJ_ENTRY_LIST &newOrder)
Sorts the adjacency list of node v according to newOrder.
Definition: Graph_d.h:1019
void moveAdj(adjEntry adjMove, Direction dir, adjEntry adjPos)
Moves adjacency entry adjMove before or after adjPos.
Definition: Graph_d.h:1052
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition: memory.h:91
ListIterator< HiddenEdgeSet * > m_it
Definition: Graph_d.h:828
edge e(int i) const
Returns the edge with index i.
Definition: Graph_d.h:1331
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:208
int stopNode(int cc) const
Returns the index of (one past) the last node in connected component cc.
Definition: Graph_d.h:1319
int maxAdjEntryIndex() const
Returns the largest used adjEntry index.
Definition: Graph_d.h:588
int startEdge(int cc) const
Returns the index of the first edge in connected component cc.
Definition: Graph_d.h:1322
Doubly linked lists.
Definition: List.h:40
#define OGDF_AUGMENT_STATICCOMPARER(type)
Add this macro to your class to turn it into a full static comparer.
Definition: comparer.h:201
int indeg() const
Returns the indegree of the node.
Definition: Graph_d.h:204
int outdeg() const
Returns the outdegree of the node.
Definition: Graph_d.h:206
adjEntry faceCyclePred() const
Returns the cyclic predecessor in face.
Definition: Graph_d.h:141
node firstNode() const
Returns the first node in the list of all nodes.
Definition: Graph_d.h:598
void outEdges(EDGELIST &edgeList) const
Returns a list with all outgoing edges of this node.
Definition: Graph_d.h:412
int numberOfCCs() const
Returns the number of connected components.
Definition: Graph_d.h:1307
int index() const
Returns the index of the edge.
Definition: Graph_d.h:323
Dynamic arrays indexed with adjacency entries.
Array< int > m_startNode
start node of each connected component in m_nodes.
Definition: Graph_d.h:1293
node v(int i) const
Returns the node with index i.
Definition: Graph_d.h:1328
Dynamic arrays indexed with edges.
Definition: EdgeArray.h:112
node succ() const
Returns the successor in the list of all nodes.
Definition: Graph_d.h:216
bool representsCombEmbedding() const
Returns true iff the graph represents a combinatorial embedding.
Definition: Graph_d.h:1132
Decralation of graph iterators.
Array< edge > m_edges
array of all edges.
Definition: Graph_d.h:1292
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Definition: Graph_d.h:278
GraphObject * tail() const
Returns the last element in the list.
Definition: GraphList.h:272
edge lastEdge() const
Returns the last edge in the list of all edges.
Definition: Graph_d.h:605
CCsInfo()
Creates a info structure associated with no graph.
Definition: Graph_d.h:1298
ostream & operator<<(ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:764
Decralation of GraphElement and GraphList classes.
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
Definition: Graph_d.h:139
int m_edgeIdCount
The Index that will be assigned to the next created edge.
Definition: Graph_d.h:478
int size() const
Returns the number of elements in the container.
Definition: GraphList.h:396
void moveAdjAfter(adjEntry adjMove, adjEntry adjAfter)
Moves adjacency entry adjMove after adjAfter.
Definition: Graph_d.h:1068
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:548
int adjEntryArrayTableSize() const
Returns the table size of adjEntry arrays associated with this graph.
Definition: Graph_d.h:595
const Graph & constGraph() const
Returns the associated graph.
Definition: Graph_d.h:1304
int numberOfEdges() const
Returns the number of edges in the graph.
Definition: Graph_d.h:581
int m_edgeArrayTableSize
The current table size of edge arrays associated with this graph.
Definition: Graph_d.h:481
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:423
int m_id
The (unique) index of the adjacency entry.
Definition: Graph_d.h:86
void inEdges(EDGELIST &edgeList) const
Returns a list with all incoming edges of this node.
Definition: Graph_d.h:403
EdgeElement(node src, node tgt, int id)
Constructs an edge element (src,tgt).
Definition: Graph_d.h:318
void collapse(NODELIST &nodesToCollapse)
Collapses all nodes in the list nodesToCollapse to the first node in the list.
Definition: Graph_d.h:988
int edgeArrayTableSize() const
Returns the table size of edge arrays associated with this graph.
Definition: Graph_d.h:593
edge firstEdge() const
Returns the first edge in the list of all edges.
Definition: Graph_d.h:603
static void copy(const T &from, T &to)
Definition: Alg.h:61
bool isBetween(adjEntry adjBefore, adjEntry adjAfter) const
Returns whether this adjacency entry lies between adjBefore and adjAfter in clockwise rotation...
Definition: Graph_d.h:385
EdgeType
The type of edges (only used in derived classes).
Definition: Graph_d.h:518
GraphObject * head() const
Returns the first element in the list.
Definition: GraphList.h:269
Bucket function using the index of an edge&#39;s source node as bucket.
Definition: Graph_d.h:1388
internal::GraphList< EdgeElement > m_edges
Definition: Graph_d.h:827
Abstract base class for adjacency entry arrays.
Definition: AdjEntryArray.h:45
ListPure< EdgeArrayBase * > m_regEdgeArrays
The registered edge arrays.
Definition: Graph_d.h:484
AdjElement * m_adjSrc
Corresponding adjacancy entry at source node.
Definition: Graph_d.h:297
ListPure< AdjEntryArrayBase * > m_regAdjArrays
The registered adjEntry arrays.
Definition: Graph_d.h:485
Doubly linked lists (maintaining the length of the list).
Definition: List.h:39
ListPure< GraphObserver * > m_regStructures
The registered graph structures.
Definition: Graph_d.h:486
static int compare(const EdgeElement &x, const EdgeElement &y)
Standard Comparer.
Definition: Graph_d.h:363
Bucket function using the index of an edge&#39;s target node as bucket.
Definition: Graph_d.h:1395
Direction
Definition: basic.h:132
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Definition: Graph_d.h:105
Class for the representation of edges.
Definition: Graph_d.h:291
void allEdges(EDGELIST &edgeList) const
Returns a list with all edges of the graph.
Definition: Graph_d.h:643
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
Definition: Graph_d.h:102
int m_numCC
the number of connected components.
Definition: Graph_d.h:1289
Base class for GraphElement lists.
Definition: GraphList.h:69
void allAdjEntries(ADJLIST &adjList) const
Returns a list with all adjacency entries of this node.
Definition: Graph_d.h:226
int m_indeg
The indegree of the node.
Definition: Graph_d.h:172
The base class for objects used by (hyper)graphs.
Definition: GraphList.h:54
AdjElement(edge e, int id)
Constructs an adjacency entry for a given edge and index.
Definition: Graph_d.h:91
adjEntry lastAdj() const
Returns the last entry in the adjacency list.
Definition: Graph_d.h:213
Class for the representation of nodes.
Definition: Graph_d.h:167
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:357
Encapsulates a pointer to a list element.
Definition: List.h:41
node lastNode() const
Returns the last node in the list of all nodes.
Definition: Graph_d.h:600
node opposite(node v) const
Returns the adjacent node different from v.
Definition: Graph_d.h:335
ListPure< NodeArrayBase * > m_regNodeArrays
The registered node arrays.
Definition: Graph_d.h:483
#define OGDF_NEW_DELETE
Makes the class use OGDF&#39;s memory allocator.
Definition: memory.h:84
adjEntry counterClockwiseFacePred() const
Returns the counter-clockwise predecessor in face.
Definition: Graph_d.h:135
AdjElement * m_twin
The corresponding adjacency entry (same edge)
Definition: Graph_d.h:83
adjEntry clockwiseFacePred() const
Returns the clockwise predecessor in face. Use faceCycleSucc instead!
Definition: Graph_d.h:131
const T & move(const T &v)
Definition: backward.hpp:243
int getBucket(const edge &e) override
Returns target index of e.
Definition: Graph_d.h:1398
std::mutex m_mutexRegArrays
The critical section for protecting shared acces to register/unregister methods.
Definition: Graph_d.h:489
bool empty() const
Returns true iff the list is empty.
Definition: GraphList.h:275
int getBucket(const edge &e) override
Returns source index of e.
Definition: Graph_d.h:1391
Info structure for maintaining connected components.
Definition: Graph_d.h:1286
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
Definition: Graph_d.h:283
const Graph * m_graph
points to the associated graph.
Definition: Graph_d.h:1288
Abstract base class for bucket functions.
Definition: basic.h:255
Array< node > m_nodes
array of all nodes.
Definition: Graph_d.h:1291
EdgeElement(node src, node tgt, AdjElement *adjSrc, AdjElement *adjTgt, int id)
Constructs an edge element (src,tgt).
Definition: Graph_d.h:309
~HiddenEdgeSet()
Restores all hidden edges.
Definition: Graph_d.h:789
edge pred() const
Returns the predecessor in the list of all edges.
Definition: Graph_d.h:342
adjEntry counterClockwiseFaceSucc() const
Returns the counter-clockwise successor in face.
Definition: Graph_d.h:133
bool isSelfLoop() const
Definition: Graph_d.h:337
int m_outdeg
The outdegree of the node.
Definition: Graph_d.h:173
int index() const
Returns the (unique) node index.
Definition: Graph_d.h:201
edge succ() const
Returns the successor in the list of all edges.
Definition: Graph_d.h:340
bool isIncident(node v) const
Returns true iff v is incident to the edge.
Definition: Graph_d.h:350
adjEntry succ() const
Returns the successor in the adjacency list.
Definition: Graph_d.h:145
void swapAdjEdges(adjEntry adj1, adjEntry adj2)
Exchanges two entries in an adjacency list.
Definition: Graph_d.h:1101
int nodeArrayTableSize() const
Returns the table size of node arrays associated with this graph.
Definition: Graph_d.h:591
void reverseAdjEdges(node v)
Reverses the adjacency list of v.
Definition: Graph_d.h:1040
void allNodes(NODELIST &nodeList) const
Returns a list with all nodes of the graph.
Definition: Graph_d.h:631
NodeElement(int id)
Constructs a node element with index id.
Definition: Graph_d.h:192
int stopEdge(int cc) const
Returns the index of (one past) the last edge in connected component cc.
Definition: Graph_d.h:1325
int maxNodeIndex() const
Returns the largest used node index.
Definition: Graph_d.h:584
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:325
Abstract base class for edge arrays.
Definition: EdgeArray.h:45
int numberOfNodes(int cc) const
Returns the number of nodes in connected component cc.
Definition: Graph_d.h:1310
The namespace for all OGDF objects.
int maxEdgeIndex() const
Returns the largest used edge index.
Definition: Graph_d.h:586
node m_node
The node whose adjacency list contains this entry.
Definition: Graph_d.h:85
int startNode(int cc) const
Returns the index of the first node in connected component cc.
Definition: Graph_d.h:1316
NodePair(node src, node tgt)
Definition: Graph_d.h:1405
Lists of graph objects (like nodes, edges, etc.).
Definition: GraphList.h:252
NodeType
The type of nodes.
Definition: Graph_d.h:525
AdjElement * m_adjTgt
Corresponding adjacancy entry at target node.
Definition: Graph_d.h:298
int numberOfNodes() const
Returns the number of nodes in the graph.
Definition: Graph_d.h:578
int index() const
Returns the index of this adjacency element.
Definition: Graph_d.h:108
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:545
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:211
int m_nodeArrayTableSize
The current table size of node arrays associated with this graph.
Definition: Graph_d.h:480
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:353
int m_id
The (unique) index of the node.
Definition: Graph_d.h:174
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
Definition: Graph_d.h:332
List< HiddenEdgeSet * > m_hiddenEdgeSets
The list of hidden edges.
Definition: Graph_d.h:492
node m_src
The source node of the edge.
Definition: Graph_d.h:295
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
Definition: Graph_d.h:575
node theNode() const
Returns the node whose adjacency list contains this element.
Definition: Graph_d.h:99
Class for adjacency list elements.
Definition: Graph_d.h:78
Abstract Base class for graph observers.
Definition: GraphObserver.h:57
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
static int compare(const NodeElement &x, const NodeElement &y)
Standard Comparer.
Definition: Graph_d.h:271
adjEntry clockwiseFaceSucc() const
Returns the clockwise successor in face. Use faceCycleSucc instead!
Definition: Graph_d.h:129
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Definition: Graph_d.h:198