Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ClusterAnalysis.h
Go to the documentation of this file.
1 
40 #pragma once
41 
42 #include <ogdf/basic/HashArray.h>
43 #include <ogdf/basic/Skiplist.h>
45 
46 namespace ogdf {
47 
48 /***
49  * @ingroup ga-cplanarity
50  *
51  * Although most parts of the code are written with efficiency in mind,
52  * this class is meant to be used in a static one-time analysis way,
53  * not for dynamic checks over and over again.
54  */
56 public:
57  static const int IsNotActiveBound;
58  static const int DefaultIndex; // Vertex index for independent bags, used to detect processing status.
59 
63  explicit ClusterAnalysis(const ClusterGraph& C, bool indyBags = false);
65  ClusterAnalysis(const ClusterGraph& C, bool oalists, bool indyBags);
67 
68  // Quantitative
70  // @param c is the cluster for which the active vertices are counted
71  int outerActive(cluster c) const;
72 
74  // @param c is the cluster for which the active vertices are counted
75  int innerActive(cluster c) const;
76 
79  int minIOALevel(node v) const { return min(minIALevel(v), minOALevel(v)); }
80 
83  int minIALevel(node v) const { return m_ialevel[v]; }
84 
87  int minOALevel(node v) const { return m_oalevel[v]; }
88 
89  // Qualitative
91 
95  bool isOuterActive(node v, cluster c) const;
96  bool isInnerActive(node v, cluster c) const;
97 
100 
104 
106  int bagIndex(node v, cluster c);
107 
109  int numberOfBags(cluster c) const;
110 
111 #if 0
112  //TODO
113  void reInit(const ClusterGraph &C);
114 #endif
115 
118  int indyBagIndex(node v);
119 
122  int numberOfIndyBags() { return m_numIndyBags; }
123 
127  cluster indyBagRoot(int i);
128 
129 protected:
132  void computeBags();
133 
136  void computeIndyBags();
137 
138 private:
145  HashArray<int, List<node>>& bagNodes, HashArray<int, bool>& indyBag,
146  Skiplist<int*>& indexNumbers, Array<cluster>& bagRoots);
147  void init();
148  void cleanUp();
149  const ClusterGraph* m_C;
150  // we keep data structures to save inner/outer activity status
151  // instead of computing them on the fly when needed
152  // keep number of activity defining adjacent edges
155 
159 
162 
166 
170  const bool m_storeoalists;
171 
173 
176  const bool m_indyBags;
178  int m_numIndyBags; //<! Number of independent bags in clustergraph
179  cluster* m_indyBagRoots; //<! Root clusters of independent bags (only when computed).
180 };
181 }
ogdf::ClusterAnalysis::indyBagIndex
int indyBagIndex(node v)
Returns independent bag index number for a vertex v.
HashArray.h
Declaration and implementation of HashArray class.
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::ClusterAnalysis::isInnerActive
bool isInnerActive(node v, cluster c) const
ogdf::ClusterAnalysis::m_indyBagRoots
cluster * m_indyBagRoots
Definition: ClusterAnalysis.h:185
ogdf::ClusterAnalysis::numberOfBags
int numberOfBags(cluster c) const
Returns number of bags for cluster c.
ogdf::ClusterAnalysis::m_indyBags
const bool m_indyBags
If true, a node partition into independent bags is computed which can be used for dividing the input ...
Definition: ClusterAnalysis.h:182
ogdf::ClusterAnalysis::m_oalists
ClusterArray< List< node > > * m_oalists
For each cluster we store the outeractive vertices. In case you want to save space,...
Definition: ClusterAnalysis.h:175
ogdf::ClusterAnalysis::computeIndyBags
void computeIndyBags()
Compute independent bags per cluster and store result as vertex-indyBag index in m_indyBagNumber.
ogdf::ClusterAnalysis
Definition: ClusterAnalysis.h:55
ogdf::ClusterAnalysis::m_oactive
NodeArray< ClusterArray< int > * > m_oactive
Definition: ClusterAnalysis.h:160
ogdf::ClusterAnalysis::isOuterActive
bool isOuterActive(node v, cluster c) const
Returns outer activity status for vertex v wrt cluster c.
ogdf::ClusterArrayBase
RegisteredArray for labeling the clusters of a ClusterGraph.
Definition: ClusterGraph.h:304
ogdf::ClusterAnalysis::cleanUp
void cleanUp()
Deletes dynamically allocated structures.
ogdf::ClusterAnalysis::bagIndex
int bagIndex(node v, cluster c)
Returns bag index number for a vertex v in cluster c.
ogdf::ClusterAnalysis::m_bagindex
NodeArray< ClusterArray< int > * > m_bagindex
We store the bag affiliation of the vertices for each cluster. A value of -1 indicates that the verte...
Definition: ClusterAnalysis.h:164
ogdf::ClusterAnalysis::oaNodes
List< node > & oaNodes(cluster c)
Returns list of outeractive vertices for cluster c. The result is only valid if lists are stored,...
ogdf::ClusterAnalysis::m_iactive
NodeArray< ClusterArray< int > * > m_iactive
Definition: ClusterAnalysis.h:159
ogdf::ClusterAnalysis::partitionCluster
void partitionCluster(ListConstIterator< node > &nodeIt, cluster c, HashArray< int, List< node >> &bagNodes, HashArray< int, bool > &indyBag, Skiplist< int * > &indexNumbers, Array< cluster > &bagRoots)
Runs through a list of vertices (starting with the one nodeIT points to) which is expected to be a fu...
ogdf::ClusterAnalysis::minOALevel
int minOALevel(node v) const
Returns the highest (smallest) level depth for which a vertex is outer active, only initialized if ve...
Definition: ClusterAnalysis.h:93
ogdf::ClusterAnalysis::m_C
const ClusterGraph * m_C
Definition: ClusterAnalysis.h:155
ogdf::ClusterAnalysis::m_bags
ClusterArray< int > * m_bags
Number of bags per cluster (stored even if vertex list is not stored)
Definition: ClusterAnalysis.h:171
ogdf::ClusterAnalysis::ClusterAnalysis
ClusterAnalysis(const ClusterGraph &C, bool indyBags=false)
Constructor. Performs all analyses and in case indyBags is set to true, also computes a partition int...
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:55
ogdf::ClusterAnalysis::m_ialevel
NodeArray< int > m_ialevel
Definition: ClusterAnalysis.h:166
ogdf::ClusterAnalysis::~ClusterAnalysis
~ClusterAnalysis()
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:214
ogdf::ClusterAnalysis::innerActive
int innerActive(cluster c) const
Returns number of inneractive vertices of cluster c.
ogdf::HashArray
Indexed arrays using hashing for element access.
Definition: HashArray.h:93
ogdf::ClusterAnalysis::m_lcaEdges
ClusterArray< List< edge > > * m_lcaEdges
For each cluster c we store the edges with lca c.
Definition: ClusterAnalysis.h:178
ogdf::ClusterAnalysis::outerActive
int outerActive(cluster c) const
Returns number of outeractive vertices of cluster c.
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63
ogdf::List< edge >
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
Skiplist.h
Declaration of class Skiplist.
ogdf::ClusterAnalysis::init
void init()
Initialize the structures, performs analyses.
ogdf::ClusterAnalysis::minIALevel
int minIALevel(node v) const
Returns the highest (smallest) level depth for which a vertex is inner active, only initialized if ve...
Definition: ClusterAnalysis.h:89
ogdf::Skiplist
A randomized skiplist.
Definition: Skiplist.h:52
ogdf::ClusterAnalysis::DefaultIndex
static const int DefaultIndex
Definition: ClusterAnalysis.h:64
ogdf::ClusterAnalysis::m_ianum
ClusterArray< int > * m_ianum
Number of inner active vertices.
Definition: ClusterAnalysis.h:170
ogdf::ClusterAnalysis::m_storeoalists
const bool m_storeoalists
If set to true (default) lists of outeractive vertices are stored.
Definition: ClusterAnalysis.h:176
ogdf::ClusterAnalysis::lcaEdges
List< edge > & lcaEdges(cluster c)
Returns list of edges for cluster c with lca c.
ClusterGraph.h
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
ogdf::ClusterAnalysis::minIOALevel
int minIOALevel(node v) const
Returns the highest (smallest) level depth for which a vertex is inner or outer active.
Definition: ClusterAnalysis.h:85
ogdf::ClusterAnalysis::m_oanum
ClusterArray< int > * m_oanum
Number of outer active vertices.
Definition: ClusterAnalysis.h:169
ogdf::ClusterAnalysis::computeBags
void computeBags()
Compute bags per cluster and store result as vertex-bag index in m_bagIndex.
ogdf::ClusterAnalysis::indyBagRoot
cluster indyBagRoot(int i)
Returns root cluster of independent bag. Note that this cluster either has direct vertex members or m...
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:46
ogdf::ClusterAnalysis::m_numIndyBags
int m_numIndyBags
Definition: ClusterAnalysis.h:184
ogdf::ClusterAnalysis::IsNotActiveBound
static const int IsNotActiveBound
Definition: ClusterAnalysis.h:63
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:339
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::ClusterAnalysis::m_indyBagNumber
NodeArray< int > m_indyBagNumber
Each independent bag has a different number.
Definition: ClusterAnalysis.h:183
ogdf::ClusterAnalysis::m_oalevel
NodeArray< int > m_oalevel
Definition: ClusterAnalysis.h:167
ogdf::ClusterAnalysis::numberOfIndyBags
int numberOfIndyBags()
Returns number of independent bags in clustergraph, -1 in case no independent bags were computed....
Definition: ClusterAnalysis.h:128