Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

Graph_d.h
Go to the documentation of this file.
1 
35 #pragma once
36 
37 #include <ogdf/basic/GraphList.h>
39 #include <array>
40 #include <mutex>
41 
42 #ifdef OGDF_DEBUG
43 # include <set>
44 #endif
45 
46 namespace ogdf {
47 
48 //
49 // in embedded graphs, adjacency lists are given in clockwise order.
50 //
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 
75 
80  friend class Graph;
83 
87  int m_id;
88 
90  explicit AdjElement(node v) : m_node(v) { }
92  AdjElement(edge e, int id) : m_edge(e), m_id(id) { }
93 
94 public:
96  edge theEdge() const { return m_edge; }
98  operator edge() const { return m_edge; }
100  node theNode() const { return m_node; }
102  operator node() const { return m_node; }
103 
105  adjEntry twin() const { return m_twin; }
106 
108  node twinNode() const { return m_twin->m_node; }
109 
111  int index() const { return m_id; }
112 
114  bool isSource() const;
115 
126  bool isBetween(adjEntry adjBefore, adjEntry adjAfter) const;
127 
128  // traversing faces in clockwise (resp. counter-clockwise) order
129  // (if face is an interior face)
130 
132  adjEntry clockwiseFaceSucc() const { return m_twin->cyclicPred(); }
134  adjEntry clockwiseFacePred() const { return cyclicSucc()->m_twin; }
136  adjEntry counterClockwiseFaceSucc() const { return m_twin->cyclicSucc(); }
138  adjEntry counterClockwiseFacePred() const { return cyclicPred()->m_twin; }
139 
140  // default is traversing faces in clockwise order
142  adjEntry faceCycleSucc() const { return clockwiseFaceSucc(); }
144  adjEntry faceCyclePred() const { return clockwiseFacePred(); }
145 
146 
148  adjEntry succ() const { return static_cast<adjEntry>(m_next); }
150  adjEntry pred() const { return static_cast<adjEntry>(m_prev); }
151 
153  adjEntry cyclicSucc() const;
155  adjEntry cyclicPred() const;
156 
157 #ifdef OGDF_DEBUG
158  const Graph *graphOf() const;
159 #endif
160 
162  static int compare(const AdjElement& x,const AdjElement& y) { return x.m_id-y.m_id; }
164 
166 };
167 
170  friend class Graph;
172 
173  //GraphList<AdjElement> m_adjEdges; //!< The adjacency list of the node.
174  int m_indeg;
175  int m_outdeg;
176  int m_id;
177 
178 #ifdef OGDF_DEBUG
179  // we store the graph containing this node for debugging purposes
180  const Graph *m_pGraph;
181 #endif
182 
183 
185 #ifdef OGDF_DEBUG
186 
191  NodeElement(const Graph *pGraph, int id) :
192  m_indeg(0), m_outdeg(0), m_id(id), m_pGraph(pGraph) { }
193 #else
194  NodeElement(int id) : m_indeg(0), m_outdeg(0), m_id(id) { }
195 #endif
196 
197 
198 public:
201 
203  int index() const { return m_id; }
204 
206  int indeg() const { return m_indeg; }
208  int outdeg() const { return m_outdeg; }
210  int degree() const { return m_indeg + m_outdeg; }
211 
213  adjEntry firstAdj() const { return adjEntries.head(); }
215  adjEntry lastAdj () const { return adjEntries.tail(); }
216 
218  node succ() const { return static_cast<node>(m_next); }
220  node pred() const { return static_cast<node>(m_prev); }
221 
223 
227  template<class ADJLIST>
228  void allAdjEntries(ADJLIST &adjList) const {
229  adjList.clear();
230  for(adjEntry adj : this->adjEntries) {
231  adjList.pushBack(adj);
232  }
233  }
234 
236 
243  template<class EDGELIST>
244  void adjEdges(EDGELIST &edgeList) const {
245  edgeList.clear();
246  for(adjEntry adj : this->adjEntries) {
247  edgeList.pushBack(adj->theEdge());
248  }
249  }
250 
252 
256  template<class EDGELIST>
257  void inEdges(EDGELIST &edgeList) const;
258 
260 
264  template<class EDGELIST>
265  void outEdges(EDGELIST &edgeList) const;
266 
267 #ifdef OGDF_DEBUG
268  const Graph *graphOf() const { return m_pGraph; }
270 #endif
271 
273  static int compare(const NodeElement& x,const NodeElement& y) { return x.m_id-y.m_id; }
275 
277 };
278 
280 {
281  return (m_next) ? static_cast<adjEntry>(m_next) : m_node->firstAdj();
282 }
283 
285 {
286  return (m_prev) ? static_cast<adjEntry>(m_prev) : m_node->lastAdj();
287 }
288 
289 
290 
293  friend class Graph;
295 
300  int m_id; // The (unique) index of the node.
301 
303 
310  EdgeElement(node src, node tgt, AdjElement *adjSrc, AdjElement *adjTgt, int id) :
311  m_src(src), m_tgt(tgt), m_adjSrc(adjSrc), m_adjTgt(adjTgt), m_id(id) { }
312 
314 
319  EdgeElement(node src, node tgt, int id) :
320  m_src(src), m_tgt(tgt), m_id(id) { }
321 
322 public:
324  int index() const { return m_id; }
326  node source() const { return m_src; }
328  node target() const { return m_tgt; }
330  std::array<node, 2> nodes() const { return std::array<node, 2>{{m_src, m_tgt}}; }
331 
333  adjEntry adjSource() const { return m_adjSrc; }
335  adjEntry adjTarget() const { return m_adjTgt; }
336 
338  node opposite(node v) const { return (v == m_src) ? m_tgt : m_src; }
339 
341  bool isSelfLoop() const { return m_src == m_tgt; }
342 
344  bool isInvertedDirected(edge e) const { return m_src == e->target() && m_tgt == e->source(); }
345 
347  bool isParallelDirected(edge e) const { return m_src == e->source() && m_tgt == e->target(); }
348 
350  bool isParallelUndirected(edge e) const { return isParallelDirected(e) || isInvertedDirected(e); }
351 
353  edge succ() const { return static_cast<edge>(m_next); }
355  edge pred() const { return static_cast<edge>(m_prev); }
356 
357 #ifdef OGDF_DEBUG
358  const Graph *graphOf() const { return m_src->graphOf(); }
360 #endif
361 
363  bool isIncident(node v) const { return v == m_src || v == m_tgt; }
364 
366  bool isAdjacent(edge e) const { return isIncident(e->m_src) || isIncident(e->m_tgt); }
367 
369  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); }
370 
373  adjEntry getAdj(node v) const {
374  OGDF_ASSERT(this->isIncident(v));
375  return v == m_src ? m_adjSrc : m_adjTgt;
376  }
377 
379  static int compare(const EdgeElement& x,const EdgeElement& y) { return x.m_id-y.m_id; }
381 
383 
384 #ifdef OGDF_DEBUG
385 private:
386  bool m_hidden = false;
387 #endif
388 };
389 
390 #ifdef OGDF_DEBUG
391 inline const Graph *AdjElement::graphOf() const {
392  return m_node->graphOf();
393 }
394 #endif
395 
396 inline bool AdjElement::isSource() const {
397  return this == m_edge->adjSource();
398 }
399 
400 inline bool AdjElement::isBetween(adjEntry adjBefore, adjEntry adjAfter) const {
401 #ifdef OGDF_DEBUG
402  node v = this->theNode();
403  OGDF_ASSERT(adjBefore->theNode() == v);
404  OGDF_ASSERT(adjAfter->theNode() == v);
405 #endif
406  bool result = this != adjBefore && this != adjAfter && adjBefore != adjAfter;
407 
408  if (result) {
409  adjEntry adj = adjBefore;
410  for (; adj != this && adj != adjAfter; adj = adj->cyclicSucc());
411  result = adj == this;
412  }
413 
414  return result;
415 }
416 
417 template<class EDGELIST>
418 void NodeElement::inEdges(EDGELIST &edgeList) const {
419  edgeList.clear();
420  for(adjEntry adj : this->adjEntries) {
421  edge e = adj->theEdge();
422  if (adj == e->adjTarget()) edgeList.pushBack(e);
423  }
424 }
425 
426 template<class EDGELIST>
427 void NodeElement::outEdges(EDGELIST &edgeList) const {
428  edgeList.clear();
429  for(adjEntry adj : this->adjEntries) {
430  edge e = adj->theEdge();
431  if (adj == e->adjSource()) edgeList.pushBack(e);
432  }
433 }
434 
435 class NodeArrayBase;
436 class EdgeArrayBase;
437 class AdjEntryArrayBase;
438 template<class T> class NodeArray;
439 template<class T> class EdgeArray;
440 template<class T> class AdjEntryArray;
442 
443 namespace internal {
444 template<typename CONTAINER> inline void getAllNodes(const Graph& G, CONTAINER& nodes);
445 template<typename CONTAINER> inline void getAllEdges(const Graph& G, CONTAINER& edges);
446 }
447 
449 
493 {
494 public:
496 private:
497  int m_nodeIdCount;
499 
502 
507 
508 #ifndef OGDF_MEMORY_POOL_NTS
509  mutable std::mutex m_mutexRegArrays;
510 #endif
511 
513 
514 public:
515 
522 
529 
531 
536 
538  enum class EdgeType {
539  association = 0,
540  generalization = 1,
541  dependency = 2
542  };
543 
545  enum class NodeType {
546  vertex = 0,
547  dummy = 1,
548  generalizationMerger = 2,
549  generalizationExpander = 3,
550  highDegreeExpander = 4,
551  lowDegreeExpander = 5,
552  associationClass = 6
553  };
554 
556 
557 
563 
566 
569 
571 
572 
574  Graph();
575 
577 
584  Graph(const Graph &G);
585 
587  virtual ~Graph();
588 
593 
595  bool empty() const { return nodes.empty(); }
596 
598  int numberOfNodes() const { return nodes.size(); }
599 
601  int numberOfEdges() const { return edges.size(); }
602 
604  int maxNodeIndex() const { return m_nodeIdCount-1; }
606  int maxEdgeIndex() const { return m_edgeIdCount-1; }
608  int maxAdjEntryIndex() const { return (m_edgeIdCount<<1)-1; }
609 
611  int nodeArrayTableSize() const { return m_nodeArrayTableSize; }
613  int edgeArrayTableSize() const { return m_edgeArrayTableSize; }
615  int adjEntryArrayTableSize() const { return m_edgeArrayTableSize << 1; }
616 
618  node firstNode() const { return nodes.head(); }
620  node lastNode () const { return nodes.tail(); }
621 
623  edge firstEdge() const { return edges.head(); }
625  edge lastEdge () const { return edges.tail(); }
626 
634  node chooseNode(std::function<bool(node)> includeNode = [](node) { return true; }, bool isFastTest = true) const;
635 
643  edge chooseEdge(std::function<bool(edge)> includeEdge = [](edge) { return true; }, bool isFastTest = true) const;
644 
646 
650  template<class CONTAINER>
651  void allNodes(CONTAINER& nodeContainer) const {
652  internal::getAllNodes<CONTAINER>(*this, nodeContainer);
653  }
654 
656 
660  template<class CONTAINER>
661  void allEdges(CONTAINER &edgeContainer) const {
662  internal::getAllEdges<CONTAINER>(*this, edgeContainer);
663  }
664 
666 
670 
672  node newNode();
673 
675 
684  node newNode(int index);
685 
687 
692  edge newEdge(node v, node w);
693 
695 
706  edge newEdge(node v, node w, int index);
707 
709 
722  edge newEdge(adjEntry adjSrc, adjEntry adjTgt, Direction dir = Direction::after);
723 
725 
735  edge newEdge(node v, adjEntry adjTgt);
736 
738 
748  edge newEdge(adjEntry adjSrc, node w);
749 
750 
752 
756 
758  virtual void delNode(node v);
759 
761  virtual void delEdge(edge e);
762 
764  virtual void clear();
765 
767 
788  {
789  friend class Graph;
790  friend class EdgeElement;
791 
792  public:
798  explicit HiddenEdgeSet(Graph &graph) : m_graph(&graph)
799  {
800  m_it = m_graph->m_hiddenEdgeSets.pushFront(this);
801  }
802 
807  {
808  if (m_graph) {
809  restore();
810  m_graph->m_hiddenEdgeSets.del(m_it);
811  }
812  }
813 
820  void hide(edge e);
821 
828  void restore(edge e);
829 
836  void restore();
837 
841  int size();
842 
843  private:
847 
848  // prevent copying
850  HiddenEdgeSet& operator=(const HiddenEdgeSet&);
851  };
852 
857 
862  void insert(const Graph &G, NodeArray<node> &nodeMap);
863 
865 
868  void insert(const Graph &G);
869 
871 
880  virtual edge split(edge e);
881 
883 
893  void unsplit(node u);
894 
896 
907  virtual void unsplit(edge eIn, edge eOut);
908 
910 
927  node splitNode(adjEntry adjStartLeft, adjEntry adjStartRight);
928 
930 
935  node contract(edge e);
936 
938 
952  void move(edge e, adjEntry adjSrc, Direction dirSrc,
953  adjEntry adjTgt, Direction dirTgt);
954 
956 
962  void moveTarget(edge e, node w);
963 
965 
973  void moveTarget(edge e, adjEntry adjTgt, Direction dir);
974 
976 
982  void moveSource(edge e, node w);
983 
985 
993  void moveSource(edge e, adjEntry adjSrc, Direction dir);
994 
996 
1004  edge searchEdge (node v, node w, bool directed = false) const;
1005 
1007  void reverseEdge(edge e);
1008 
1010  void reverseAllEdges();
1011 
1013 
1019  template<class NODELIST>
1020  void collapse(NODELIST &nodesToCollapse){
1021  node v = nodesToCollapse.popFrontRet();
1022  while (!nodesToCollapse.empty())
1023  {
1024  node w = nodesToCollapse.popFrontRet();
1025  adjEntry adj = w->firstAdj();
1026  while (adj != nullptr)
1027  {
1028  adjEntry succ = adj->succ();
1029  edge e = adj->theEdge();
1030  if (e->source() == v || e->target() == v)
1031  delEdge(e);
1032  else if (e->source() == w)
1033  moveSource(e,v);
1034  else
1035  moveTarget(e,v);
1036  adj = succ;
1037  }
1038  delNode(w);
1039  }
1040  }
1041 
1043 
1050  template<class ADJ_ENTRY_LIST>
1051  void sort(node v, const ADJ_ENTRY_LIST &newOrder) {
1052 #ifdef OGDF_DEBUG
1053  std::set<int> entries;
1054  int counter = 0;
1055 
1056  for(adjEntry adj : newOrder) {
1057  entries.insert(adj->index());
1058  OGDF_ASSERT(adj->theNode() == v);
1059  counter++;
1060  }
1061 
1062  OGDF_ASSERT(counter == v->degree());
1063  OGDF_ASSERT(entries.size() == static_cast<unsigned int>(v->degree()));
1064 #endif
1065  v->adjEntries.sort(newOrder);
1066  }
1067 
1069 
1073  v->adjEntries.reverse();
1074  }
1075 
1077 
1084  void moveAdj(adjEntry adjMove, Direction dir, adjEntry adjPos) {
1085  OGDF_ASSERT(adjMove != nullptr);
1086  OGDF_ASSERT(adjPos != nullptr);
1087  OGDF_ASSERT(adjMove->graphOf() == this);
1088  OGDF_ASSERT(adjPos->graphOf() == this);
1089  internal::GraphList<AdjElement> &adjList = adjMove->m_node->adjEntries;
1090  adjList.move(adjMove, adjList, adjPos, dir);
1091  }
1092 
1094 
1100  void moveAdjAfter(adjEntry adjMove, adjEntry adjAfter) {
1101  OGDF_ASSERT(adjMove != nullptr);
1102  OGDF_ASSERT(adjAfter != nullptr);
1103  OGDF_ASSERT(adjMove->graphOf() == this);
1104  OGDF_ASSERT(adjAfter->graphOf() == this);
1105  adjMove->m_node->adjEntries.moveAfter(adjMove,adjAfter);
1106  }
1107 
1109 
1115  void moveAdjBefore(adjEntry adjMove, adjEntry adjBefore) {
1116  OGDF_ASSERT(adjMove != nullptr);
1117  OGDF_ASSERT(adjBefore != nullptr);
1118  OGDF_ASSERT(adjMove->graphOf() == this);
1119  OGDF_ASSERT(adjBefore->graphOf() == this);
1120  adjMove->m_node->adjEntries.moveBefore(adjMove,adjBefore);
1121  }
1122 
1124  void reverseAdjEdges();
1125 
1127 
1133  void swapAdjEdges(adjEntry adj1, adjEntry adj2) {
1134  OGDF_ASSERT(adj1->theNode() == adj2->theNode());
1135  OGDF_ASSERT(adj1->graphOf() == this);
1136 
1137  adj1->theNode()->adjEntries.swap(adj1,adj2);
1138  }
1139 
1140 
1142 
1146 
1148 
1158  int genus() const;
1159 
1161 
1165  return genus() == 0;
1166  }
1167 
1168 #ifdef OGDF_DEBUG
1169  void consistencyCheck() const;
1171 #endif
1172 
1174 
1180 
1182 
1189  ListIterator<NodeArrayBase*> registerArray(NodeArrayBase *pNodeArray) const;
1190 
1192 
1199  ListIterator<EdgeArrayBase*> registerArray(EdgeArrayBase *pEdgeArray) const;
1200 
1202 
1210  ListIterator<AdjEntryArrayBase*> registerArray(AdjEntryArrayBase *pAdjArray) const;
1211 
1213 
1219  ListIterator<GraphObserver*> registerStructure(GraphObserver *pStructure) const;
1220 
1222 
1226  void unregisterArray(ListIterator<NodeArrayBase*> it) const;
1227 
1229 
1233  void unregisterArray(ListIterator<EdgeArrayBase*> it) const;
1234 
1236 
1240  void unregisterArray(ListIterator<AdjEntryArrayBase*> it) const;
1241 
1243 
1247  void unregisterStructure(ListIterator<GraphObserver*> it) const;
1248 
1250  template<class ArrayBase>
1251  void moveRegisterArray(ListIterator<ArrayBase*> it, ArrayBase *pArray) const {
1252 #ifndef OGDF_MEMORY_POOL_NTS
1253  std::lock_guard<std::mutex> guard(m_mutexRegArrays);
1254 #endif
1255  *it = pArray;
1256  }
1257 
1259 
1284  void resetEdgeIdCount(int maxId);
1285 
1286 
1288 
1292 
1301  Graph &operator=(const Graph &G);
1302 
1304 
1306 
1307 public:
1308 
1311 
1312  const Graph *m_graph;
1313  int m_numCC;
1314 
1319 
1320  public:
1322  CCsInfo() : m_graph(nullptr), m_numCC(0) { }
1323 
1325  explicit CCsInfo(const Graph& G);
1326 
1328  const Graph &constGraph() const { return *m_graph; }
1329 
1331  int numberOfCCs() const { return m_numCC; }
1332 
1334  int numberOfNodes(int cc) const { return stopNode(cc) - startNode(cc); }
1335 
1337  int numberOfEdges(int cc) const { return stopEdge(cc) - startEdge(cc); }
1338 
1340  int startNode(int cc) const { return m_startNode[cc]; }
1341 
1343  int stopNode (int cc) const { return m_startNode[cc+1]; }
1344 
1346  int startEdge(int cc) const { return m_startEdge[cc]; }
1347 
1349  int stopEdge (int cc) const { return m_startEdge[cc+1]; }
1350 
1352  node v(int i) const { return m_nodes[i]; }
1353 
1355  edge e(int i) const { return m_edges[i]; }
1356  };
1357 
1358 protected:
1359  void construct(const Graph &G, NodeArray<node> &mapNode, EdgeArray<edge> &mapEdge);
1360 
1361  void assign(const Graph &G, NodeArray<node> &mapNode, EdgeArray<edge> &mapEdge);
1362 
1364 
1368  void constructInitByNodes(
1369  const Graph &G,
1370  const List<node> &nodeList,
1371  NodeArray<node> &mapNode,
1372  EdgeArray<edge> &mapEdge);
1373 
1374  void constructInitByActiveNodes(
1375  const List<node> &nodeList,
1376  const NodeArray<bool> &activeNodes,
1377  NodeArray<node> &mapNode,
1378  EdgeArray<edge> &mapEdge);
1379 
1381  void constructInitByCC(
1382  const CCsInfo &info,
1383  int cc,
1384  NodeArray<node> &mapNode,
1385  EdgeArray<edge> &mapEdge);
1386 
1387 private:
1388  void copy(const Graph &G, NodeArray<node> &mapNode,
1389  EdgeArray<edge> &mapEdge);
1390  void copy(const Graph &G);
1391 
1392  edge createEdgeElement(node v, node w, adjEntry adjSrc, adjEntry adjTgt);
1393  node pureNewNode();
1394 
1395  // moves adjacency entry to node w
1396  void moveAdj(adjEntry adj, node w);
1397 
1401  void resetTableSizes();
1402 
1405  void reinitArrays(bool doResetTableSizes = true);
1406  void reinitStructures();
1407  void resetAdjEntryIndex(int newIndex, int oldIndex);
1408 
1412  void restoreAllEdges();
1413 };
1414 
1415 OGDF_EXPORT std::ostream & operator<<(std::ostream &os, const Graph::EdgeType &et);
1416 
1419 public:
1421  int getBucket(const edge &e) override { return e->source()->index(); }
1422 };
1423 
1426 public:
1428  int getBucket(const edge &e) override { return e->target()->index(); }
1429 };
1430 
1431 namespace internal {
1432 
1433 template<typename CONTAINER>
1434 inline void getAllNodes(const Graph& G, CONTAINER& nodes) {
1435  nodes.clear();
1436  for (node v : G.nodes) {
1437  nodes.pushBack(v);
1438  }
1439 }
1440 
1441 template<>
1442 inline void getAllNodes(const Graph& G, Array<node>& nodes) {
1443  nodes.init(G.numberOfNodes());
1444  int i = 0;
1445  for (node v : G.nodes) {
1446  nodes[i++] = v;
1447  }
1448 }
1449 
1450 template<typename CONTAINER>
1451 inline void getAllEdges(const Graph& G, CONTAINER& edges) {
1452  edges.clear();
1453  for (edge v : G.edges) {
1454  edges.pushBack(v);
1455  }
1456 }
1457 
1458 template<>
1459 inline void getAllEdges(const Graph& G, Array<edge>& edges) {
1460  edges.init(G.numberOfEdges());
1461  int i = 0;
1462  for (edge v : G.edges) {
1463  edges[i++] = v;
1464  }
1465 }
1466 
1467 }
1468 
1469 struct NodePair {
1470  node source = nullptr;
1471  node target = nullptr;
1472  NodePair() = default;
1473  NodePair(node src, node tgt) : source(src), target(tgt) {}
1474 };
1475 
1476 inline std::ostream &operator<<(std::ostream &os, const NodePair& np) {
1477  os << "(" << np.source << "," << np.target << ")";
1478  return os;
1479 }
1480 
1481 }
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:328
void adjEdges(EDGELIST &edgeList) const
Returns a list with all edges incident to this node.
Definition: Graph_d.h:244
void getAllEdges(const Graph &G, Array< edge > &edges)
Definition: Graph_d.h:1459
int m_nodeIdCount
The Index that will be assigned to the next created node.
Definition: Graph_d.h:495
void moveAdjBefore(adjEntry adjMove, adjEntry adjBefore)
Moves adjacency entry adjMove before adjBefore.
Definition: Graph_d.h:1115
bool isSource() const
Returns true iff this is the source adjacency entry of the corresponding edge.
Definition: Graph_d.h:396
Abstract base class for node arrays.
Definition: NodeArray.h:45
node m_tgt
The target node of the edge.
Definition: Graph_d.h:297
EdgeElement * edge
The type of edges.
Definition: Graph_d.h:67
Array< int > m_startEdge
start edge of each connected component in m_edges.
Definition: Graph_d.h:1318
Functionality for temporarily hiding edges in constant time.
Definition: Graph_d.h:787
int numberOfEdges(int cc) const
Returns the number of edges in connected component cc.
Definition: Graph_d.h:1337
adjEntry pred() const
Returns the predecessor in the adjacency list.
Definition: Graph_d.h:150
HiddenEdgeSet(Graph &graph)
Creates a new set of hidden edges.
Definition: Graph_d.h:798
node pred() const
Returns the predecessor in the list of all nodes.
Definition: Graph_d.h:220
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:96
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
edge m_edge
The associated edge.
Definition: Graph_d.h:85
#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:162
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
Definition: Graph_d.h:333
AdjElement(node v)
Constructs an adjacency element for a given node.
Definition: Graph_d.h:90
void sort(node v, const ADJ_ENTRY_LIST &newOrder)
Sorts the adjacency list of node v according to newOrder.
Definition: Graph_d.h:1051
void moveAdj(adjEntry adjMove, Direction dir, adjEntry adjPos)
Moves adjacency entry adjMove before or after adjPos.
Definition: Graph_d.h:1084
void init()
Reinitializes the array to an array with empty index set.
Definition: Array.h:354
#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:845
edge e(int i) const
Returns the edge with index i.
Definition: Graph_d.h:1355
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:210
int stopNode(int cc) const
Returns the index of (one past) the last node in connected component cc.
Definition: Graph_d.h:1343
int maxAdjEntryIndex() const
Returns the largest used adjEntry index.
Definition: Graph_d.h:608
int startEdge(int cc) const
Returns the index of the first edge in connected component cc.
Definition: Graph_d.h:1346
Doubly linked lists.
Definition: List.h:41
#define OGDF_AUGMENT_STATICCOMPARER(type)
Add this macro to your class to turn it into a full static comparer.
Definition: comparer.h:203
int indeg() const
Returns the indegree of the node.
Definition: Graph_d.h:206
int outdeg() const
Returns the outdegree of the node.
Definition: Graph_d.h:208
adjEntry faceCyclePred() const
Returns the cyclic predecessor in face.
Definition: Graph_d.h:144
node firstNode() const
Returns the first node in the list of all nodes.
Definition: Graph_d.h:618
void outEdges(EDGELIST &edgeList) const
Returns a list with all outgoing edges of this node.
Definition: Graph_d.h:427
int numberOfCCs() const
Returns the number of connected components.
Definition: Graph_d.h:1331
int index() const
Returns the index of the edge.
Definition: Graph_d.h:324
Dynamic arrays indexed with adjacency entries.
Array< int > m_startNode
start node of each connected component in m_nodes.
Definition: Graph_d.h:1317
node v(int i) const
Returns the node with index i.
Definition: Graph_d.h:1352
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:218
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:350
bool representsCombEmbedding() const
Returns true iff the graph represents a combinatorial embedding.
Definition: Graph_d.h:1164
Decralation of graph iterators.
Array< edge > m_edges
array of all edges.
Definition: Graph_d.h:1316
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Definition: Graph_d.h:279
GraphObject * tail() const
Returns the last element in the list.
Definition: GraphList.h:262
edge lastEdge() const
Returns the last edge in the list of all edges.
Definition: Graph_d.h:625
CCsInfo()
Creates a info structure associated with no graph.
Definition: Graph_d.h:1322
Decralation of GraphElement and GraphList classes.
void moveRegisterArray(ListIterator< ArrayBase *> it, ArrayBase *pArray) const
Move the registration it of an graph element array to pArray (used with move semantics for graph elem...
Definition: Graph_d.h:1251
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
Definition: Graph_d.h:142
int m_edgeIdCount
The Index that will be assigned to the next created edge.
Definition: Graph_d.h:498
int size() const
Returns the number of elements in the container.
Definition: GraphList.h:386
void moveAdjAfter(adjEntry adjMove, adjEntry adjAfter)
Moves adjacency entry adjMove after adjAfter.
Definition: Graph_d.h:1100
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:568
int adjEntryArrayTableSize() const
Returns the table size of adjEntry arrays associated with this graph.
Definition: Graph_d.h:615
const Graph & constGraph() const
Returns the associated graph.
Definition: Graph_d.h:1328
int numberOfEdges() const
Returns the number of edges in the graph.
Definition: Graph_d.h:601
int m_edgeArrayTableSize
The current table size of edge arrays associated with this graph.
Definition: Graph_d.h:501
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
int m_id
The (unique) index of the adjacency entry.
Definition: Graph_d.h:87
void inEdges(EDGELIST &edgeList) const
Returns a list with all incoming edges of this node.
Definition: Graph_d.h:418
EdgeElement(node src, node tgt, int id)
Constructs an edge element (src,tgt).
Definition: Graph_d.h:319
void collapse(NODELIST &nodesToCollapse)
Collapses all nodes in the list nodesToCollapse to the first node in the list.
Definition: Graph_d.h:1020
int edgeArrayTableSize() const
Returns the table size of edge arrays associated with this graph.
Definition: Graph_d.h:613
edge firstEdge() const
Returns the first edge in the list of all edges.
Definition: Graph_d.h:623
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:400
EdgeType
The type of edges (only used in derived classes).
Definition: Graph_d.h:538
GraphObject * head() const
Returns the first element in the list.
Definition: GraphList.h:259
Bucket function using the index of an edge&#39;s source node as bucket.
Definition: Graph_d.h:1418
internal::GraphList< EdgeElement > m_edges
Definition: Graph_d.h:844
Abstract base class for adjacency entry arrays.
Definition: AdjEntryArray.h:45
ListPure< EdgeArrayBase * > m_regEdgeArrays
The registered edge arrays.
Definition: Graph_d.h:504
AdjElement * m_adjSrc
Corresponding adjacancy entry at source node.
Definition: Graph_d.h:298
ListPure< AdjEntryArrayBase * > m_regAdjArrays
The registered adjEntry arrays.
Definition: Graph_d.h:505
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
ListPure< GraphObserver * > m_regStructures
The registered graph structures.
Definition: Graph_d.h:506
bool isInvertedDirected(edge e) const
Returns true iff edge e is an inverted edge to this (directed) edge.
Definition: Graph_d.h:344
static int compare(const EdgeElement &x, const EdgeElement &y)
Standard Comparer.
Definition: Graph_d.h:379
Bucket function using the index of an edge&#39;s target node as bucket.
Definition: Graph_d.h:1425
Direction
Definition: basic.h:126
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Definition: Graph_d.h:108
Class for the representation of edges.
Definition: Graph_d.h:292
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
Definition: Graph_d.h:105
int m_numCC
the number of connected components.
Definition: Graph_d.h:1313
Base class for GraphElement lists.
Definition: GraphList.h:68
void allAdjEntries(ADJLIST &adjList) const
Returns a list with all adjacency entries of this node.
Definition: Graph_d.h:228
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63
int m_indeg
The indegree of the node.
Definition: Graph_d.h:174
The base class for objects used by (hyper)graphs.
Definition: GraphList.h:54
bool isAdjacent(edge e) const
Returns true iff e is adjacent to the edge.
Definition: Graph_d.h:366
AdjElement(edge e, int id)
Constructs an adjacency entry for a given edge and index.
Definition: Graph_d.h:92
adjEntry lastAdj() const
Returns the last entry in the adjacency list.
Definition: Graph_d.h:215
Class for the representation of nodes.
Definition: Graph_d.h:169
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:373
Encapsulates a pointer to a list element.
Definition: List.h:42
node lastNode() const
Returns the last node in the list of all nodes.
Definition: Graph_d.h:620
node opposite(node v) const
Returns the adjacent node different from v.
Definition: Graph_d.h:338
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:330
ListPure< NodeArrayBase * > m_regNodeArrays
The registered node arrays.
Definition: Graph_d.h:503
#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:138
AdjElement * m_twin
The corresponding adjacency entry (same edge)
Definition: Graph_d.h:84
adjEntry clockwiseFacePred() const
Returns the clockwise predecessor in face. Use faceCycleSucc instead!
Definition: Graph_d.h:134
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:1428
std::mutex m_mutexRegArrays
The critical section for protecting shared acces to register/unregister methods.
Definition: Graph_d.h:509
bool empty() const
Returns true iff the list is empty.
Definition: GraphList.h:265
int getBucket(const edge &e) override
Returns source index of e.
Definition: Graph_d.h:1421
Info structure for maintaining connected components.
Definition: Graph_d.h:1310
adjEntry cyclicPred() const
Returns the cyclic predecessor in the adjacency list.
Definition: Graph_d.h:284
const Graph * m_graph
points to the associated graph.
Definition: Graph_d.h:1312
Abstract base class for bucket functions.
Definition: basic.h:226
Array< node > m_nodes
array of all nodes.
Definition: Graph_d.h:1315
EdgeElement(node src, node tgt, AdjElement *adjSrc, AdjElement *adjTgt, int id)
Constructs an edge element (src,tgt).
Definition: Graph_d.h:310
~HiddenEdgeSet()
Restores all hidden edges.
Definition: Graph_d.h:806
edge pred() const
Returns the predecessor in the list of all edges.
Definition: Graph_d.h:355
adjEntry counterClockwiseFaceSucc() const
Returns the counter-clockwise successor in face.
Definition: Graph_d.h:136
bool isSelfLoop() const
Returns true iff the edge is a self-loop (source node = target node).
Definition: Graph_d.h:341
int m_outdeg
The outdegree of the node.
Definition: Graph_d.h:175
int index() const
Returns the (unique) node index.
Definition: Graph_d.h:203
edge succ() const
Returns the successor in the list of all edges.
Definition: Graph_d.h:353
bool isIncident(node v) const
Returns true iff v is incident to the edge.
Definition: Graph_d.h:363
adjEntry succ() const
Returns the successor in the adjacency list.
Definition: Graph_d.h:148
void swapAdjEdges(adjEntry adj1, adjEntry adj2)
Exchanges two entries in an adjacency list.
Definition: Graph_d.h:1133
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:347
int nodeArrayTableSize() const
Returns the table size of node arrays associated with this graph.
Definition: Graph_d.h:611
void reverseAdjEdges(node v)
Reverses the adjacency list of v.
Definition: Graph_d.h:1072
NodeElement(int id)
Constructs a node element with index id.
Definition: Graph_d.h:194
int stopEdge(int cc) const
Returns the index of (one past) the last edge in connected component cc.
Definition: Graph_d.h:1349
void allNodes(CONTAINER &nodeContainer) const
Returns a container with all nodes of the graph.
Definition: Graph_d.h:651
int maxNodeIndex() const
Returns the largest used node index.
Definition: Graph_d.h:604
void getAllNodes(const Graph &G, Array< node > &nodes)
Definition: Graph_d.h:1442
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:326
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:1334
The namespace for all OGDF objects.
int maxEdgeIndex() const
Returns the largest used edge index.
Definition: Graph_d.h:606
node m_node
The node whose adjacency list contains this entry.
Definition: Graph_d.h:86
void allEdges(CONTAINER &edgeContainer) const
Returns a container with all edges of the graph.
Definition: Graph_d.h:661
int startNode(int cc) const
Returns the index of the first node in connected component cc.
Definition: Graph_d.h:1340
NodePair(node src, node tgt)
Definition: Graph_d.h:1473
Lists of graph objects (like nodes, edges, etc.).
Definition: GraphList.h:242
NodeType
The type of nodes.
Definition: Graph_d.h:545
AdjElement * m_adjTgt
Corresponding adjacancy entry at target node.
Definition: Graph_d.h:299
int numberOfNodes() const
Returns the number of nodes in the graph.
Definition: Graph_d.h:598
int index() const
Returns the index of this adjacency element.
Definition: Graph_d.h:111
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:565
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:213
int m_nodeArrayTableSize
The current table size of node arrays associated with this graph.
Definition: Graph_d.h:500
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:369
int m_id
The (unique) index of the node.
Definition: Graph_d.h:176
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
Definition: Graph_d.h:335
List< HiddenEdgeSet * > m_hiddenEdgeSets
The list of hidden edges.
Definition: Graph_d.h:512
node m_src
The source node of the edge.
Definition: Graph_d.h:296
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
Definition: Graph_d.h:595
node theNode() const
Returns the node whose adjacency list contains this element.
Definition: Graph_d.h:100
Class for adjacency list elements.
Definition: Graph_d.h:79
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:942
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:273
adjEntry clockwiseFaceSucc() const
Returns the clockwise successor in face. Use faceCycleSucc instead!
Definition: Graph_d.h:132
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Definition: Graph_d.h:200