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