Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ExpansionGraph.h
Go to the documentation of this file.
1 
35 #pragma once
36 
37 #include <ogdf/basic/Array.h>
38 #include <ogdf/basic/Graph.h>
39 #include <ogdf/basic/SList.h>
40 #include <ogdf/basic/basic.h>
41 
42 namespace ogdf {
43 
44 
51 public:
52  // constructor
53  ExpansionGraph(const Graph& G);
54 
55  // number of biconnected components of G
56  int numberOfBCs() const { return m_component.high() + 1; }
57 
58  // returns number of bic. component containing edge e
59  int componentNumber(edge e) const { return m_compNum[e]; }
60 
61  void setComponentNumber(edge e, int i) { m_compNum[e] = i; }
62 
63  // returns list of edges contained in component i
64  const SListPure<edge>& component(int i) const { return m_component[i]; }
65 
66  // returns list of components containing vertex v
67  const SList<int>& adjacentComponents(node v) const { return m_adjComponents[v]; }
68 
69  // original node of node v
70  // Precond.: v is a node in the expansion graph
71  node original(node v) const { return m_vOrig[v]; }
72 
74  node vOrig = m_vOrig[v];
75  return (vOrig != nullptr) ? vOrig : m_vRep[v];
76  }
77 
78  node copy(node vG) const { return m_vCopy[vG]; }
79 
80  // original edge of edge e
81  // Precond.: e is a edge in the expansion graph
82  edge original(edge e) const { return m_eOrig[e]; }
83 
84  // sets the original node of vCopy to vOriginal
85  void setOriginal(node vCopy, node vOriginal) { m_vOrig[vCopy] = vOriginal; }
86 
87  // initializes to the expansion graph of the i-th biconnected component
88  // of G
89  void init(int i);
90 
91  // initializes to the expansion graph of G
92  // advantage is that the vertices in the created copy are created in the
93  // order in which the corresponding originals appear in the list of nodes
94  // in G and therefore mostly have the same indices
95  // mainly for debbugging purposes
96  void init(const Graph& G);
97 
98 private:
99  node getCopy(node vOrig) {
100  node vCopy = m_vCopy[vOrig];
101  if (vCopy == nullptr) {
102  vCopy = newNode();
103  m_vOrig[m_vCopy[vOrig] = vCopy] = vOrig;
104  }
105  return vCopy;
106  }
107 
108  EdgeArray<int> m_compNum; // component of edge e
109  Array<SListPure<edge>> m_component; // edges in i-th biconnected comp.
110  NodeArray<SList<int>> m_adjComponents; // components containing v
111  NodeArray<node> m_vCopy; // copy of original vertex
112  NodeArray<node> m_vOrig; // original vertex of copy
114  EdgeArray<edge> m_eOrig; // original edge of copy
115 };
116 
117 
118 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
Graph.h
Includes declaration of graph class.
ogdf::ExpansionGraph::copy
node copy(node vG) const
Definition: ExpansionGraph.h:78
ogdf::ExpansionGraph::original
node original(node v) const
Definition: ExpansionGraph.h:71
ogdf::ExpansionGraph::m_vRep
NodeArray< node > m_vRep
Definition: ExpansionGraph.h:113
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:845
ogdf::ExpansionGraph::m_component
Array< SListPure< edge > > m_component
Definition: ExpansionGraph.h:109
ogdf::ExpansionGraph::adjacentComponents
const SList< int > & adjacentComponents(node v) const
Definition: ExpansionGraph.h:67
ogdf::ExpansionGraph::representative
node representative(node v) const
Definition: ExpansionGraph.h:73
ogdf::ExpansionGraph::m_vOrig
NodeArray< node > m_vOrig
Definition: ExpansionGraph.h:112
ogdf::ExpansionGraph::m_vCopy
NodeArray< node > m_vCopy
Definition: ExpansionGraph.h:111
ogdf::ExpansionGraph::m_eOrig
EdgeArray< edge > m_eOrig
Definition: ExpansionGraph.h:114
ogdf::ExpansionGraph::m_compNum
EdgeArray< int > m_compNum
Definition: ExpansionGraph.h:108
SList.h
Declaration of singly linked lists and iterators.
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:219
ogdf::SListPure
Singly linked lists.
Definition: SList.h:52
ogdf::ExpansionGraph::getCopy
node getCopy(node vOrig)
Definition: ExpansionGraph.h:99
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::ExpansionGraph::component
const SListPure< edge > & component(int i) const
Definition: ExpansionGraph.h:64
ogdf::ExpansionGraph::componentNumber
int componentNumber(edge e) const
Definition: ExpansionGraph.h:59
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::ExpansionGraph::original
edge original(edge e) const
Definition: ExpansionGraph.h:82
ogdf::graphics::init
void init()
Definition: graphics.h:450
ogdf::ExpansionGraph::setOriginal
void setOriginal(node vCopy, node vOriginal)
Definition: ExpansionGraph.h:85
basic.h
Basic declarations, included by all source files.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
Array.h
Declaration and implementation of Array class and Array algorithms.
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::ExpansionGraph::setComponentNumber
void setComponentNumber(edge e, int i)
Definition: ExpansionGraph.h:61
ogdf::ExpansionGraph::numberOfBCs
int numberOfBCs() const
Definition: ExpansionGraph.h:56
ogdf::ExpansionGraph
Represents expansion graph of each biconnected component of a given digraph, i.e.,...
Definition: ExpansionGraph.h:50
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::ExpansionGraph::m_adjComponents
NodeArray< SList< int > > m_adjComponents
Definition: ExpansionGraph.h:110
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716