Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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 
42 namespace ogdf {
43 
44 
51 {
52 public:
53  // constructor
54  ExpansionGraph(const Graph &G);
55 
56  // number of biconnected components of G
57  int numberOfBCs() const {
58  return m_component.high()+1;
59  }
60 
61  // returns number of bic. component containing edge e
62  int componentNumber(edge e) const {
63  return m_compNum[e];
64  }
65 
66  void setComponentNumber(edge e, int i) {
67  m_compNum[e] = i;
68  }
69 
70  // returns list of edges contained in component i
71  const SListPure<edge> &component(int i) const {
72  return m_component[i];
73  }
74 
75  // returns list of components containing vertex v
77  return m_adjComponents[v];
78  }
79 
80 
81  // original node of node v
82  // Precond.: v is a node in the expansion graph
83  node original(node v) const {
84  return m_vOrig[v];
85  }
86 
88  node vOrig = m_vOrig[v];
89  return (vOrig != nullptr) ? vOrig : m_vRep[v];
90  }
91 
92  node copy(node vG) const {
93  return m_vCopy[vG];
94  }
95 
96  // original edge of edge e
97  // Precond.: e is a edge in the expansion graph
98  edge original(edge e) const {
99  return m_eOrig[e];
100  }
101 
102  // sets the original node of vCopy to vOriginal
103  void setOriginal(node vCopy, node vOriginal) {
104  m_vOrig[vCopy] = vOriginal;
105  }
106 
107 
108  // initializes to the expansion graph of the i-th biconnected component
109  // of G
110  void init(int i);
111 
112  // initializes to the expansion graph of G
113  // advantage is that the vertices in the created copy are created in the
114  // order in which the corresponding originals appear in the list of nodes
115  // in G and therefore mostly have the same indices
116  // mainly for debbugging purposes
117  void init(const Graph &G);
118 
119 private:
120  node getCopy(node vOrig) {
121  node vCopy = m_vCopy[vOrig];
122  if (vCopy == nullptr) {
123  vCopy = newNode();
124  m_vOrig[m_vCopy[vOrig] = vCopy] = vOrig;
125  }
126  return vCopy;
127  }
128 
129  EdgeArray<int> m_compNum; // component of edge e
130  Array<SListPure<edge> > m_component; // edges in i-th biconnected comp.
131  NodeArray<SList<int> > m_adjComponents; // components containing v
132  NodeArray<node> m_vCopy; // copy of original vertex
133  NodeArray<node> m_vOrig; // original vertex of copy
135  EdgeArray<edge> m_eOrig; // original edge of copy
136 };
137 
138 
139 }
Declaration of singly linked lists and iterators.
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:200
node representative(node v) const
int componentNumber(edge e) const
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
NodeArray< SList< int > > m_adjComponents
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
Represents expansion graph of each biconnected component of a given digraph, i.e., each vertex v with in- and outdegree greater than 1 is expanded into two vertices x and y connected by an edge x->y such that all incoming edges are moved from v to x and all outgoing edges from v to y.
Singly linked lists.
Definition: SList.h:38
const SListPure< edge > & component(int i) const
int numberOfBCs() const
void setComponentNumber(edge e, int i)
EdgeArray< edge > m_eOrig
void init()
Definition: graphics.h:472
EdgeArray< int > m_compNum
node original(node v) const
node getCopy(node vOrig)
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
Declaration and implementation of EdgeArray class.
NodeArray< node > m_vCopy
NodeArray< node > m_vOrig
const SList< int > & adjacentComponents(node v) const
Class for the representation of edges.
Definition: Graph_d.h:292
Class for the representation of nodes.
Definition: Graph_d.h:169
Declaration and implementation of NodeArray class.
node copy(node vG) const
NodeArray< node > m_vRep
The namespace for all OGDF objects.
Array< SListPure< edge > > m_component
void setOriginal(node vCopy, node vOriginal)
edge original(edge e) const