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/Array.h>
43 #include <ogdf/basic/Graph.h>
44 #include <ogdf/basic/HashArray.h>
45 #include <ogdf/basic/List.h>
46 #include <ogdf/basic/basic.h>
48 
49 #include <algorithm>
50 
51 namespace ogdf {
52 template<class X>
53 class Skiplist;
54 
55 /***
56  * @ingroup ga-cplanarity
57  *
58  * Although most parts of the code are written with efficiency in mind,
59  * this class is meant to be used in a static one-time analysis way,
60  * not for dynamic checks over and over again.
61  */
63 public:
64  static const int IsNotActiveBound;
65  static const int DefaultIndex; // Vertex index for independent bags, used to detect processing status.
66 
70  explicit ClusterAnalysis(const ClusterGraph& C, bool indyBags = false);
72  ClusterAnalysis(const ClusterGraph& C, bool oalists, bool indyBags);
74 
75  // Quantitative
77  // @param c is the cluster for which the active vertices are counted
78  int outerActive(cluster c) const;
79 
81  // @param c is the cluster for which the active vertices are counted
82  int innerActive(cluster c) const;
83 
86  int minIOALevel(node v) const { return min(minIALevel(v), minOALevel(v)); }
87 
90  int minIALevel(node v) const { return m_ialevel[v]; }
91 
94  int minOALevel(node v) const { return m_oalevel[v]; }
95 
96  // Qualitative
98 
102  bool isOuterActive(node v, cluster c) const;
103  bool isInnerActive(node v, cluster c) const;
104 
107 
111 
113  int bagIndex(node v, cluster c);
114 
116  int numberOfBags(cluster c) const;
117 
118 #if 0
119  //TODO
120  void reInit(const ClusterGraph &C);
121 #endif
122 
125  int indyBagIndex(node v);
126 
129  int numberOfIndyBags() { return m_numIndyBags; }
130 
134  cluster indyBagRoot(int i);
135 
136 protected:
139  void computeBags();
140 
143  void computeIndyBags();
144 
145 private:
152  HashArray<int, List<node>>& bagNodes, HashArray<int, bool>& indyBag,
153  Skiplist<int*>& indexNumbers, Array<cluster>& bagRoots);
154  void init();
155  void cleanUp();
156  const ClusterGraph* m_C;
157  // we keep data structures to save inner/outer activity status
158  // instead of computing them on the fly when needed
159  // keep number of activity defining adjacent edges
162 
166 
169 
173 
177  const bool m_storeoalists;
178 
180 
183  const bool m_indyBags;
185  int m_numIndyBags; //<! Number of independent bags in clustergraph
186  cluster* m_indyBagRoots; //<! Root clusters of independent bags (only when computed).
187 };
188 }
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: multilevelmixer.cpp:39
ogdf::ClusterAnalysis::isInnerActive
bool isInnerActive(node v, cluster c) const
ogdf::ClusterAnalysis::m_indyBagRoots
cluster * m_indyBagRoots
Definition: ClusterAnalysis.h:192
Graph.h
Includes declaration of graph class.
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:189
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:182
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:62
ogdf::ClusterAnalysis::m_oactive
NodeArray< ClusterArray< int > * > m_oactive
Definition: ClusterAnalysis.h:167
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:311
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:171
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:166
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:100
ogdf::ClusterAnalysis::m_C
const ClusterGraph * m_C
Definition: ClusterAnalysis.h:162
ogdf::ClusterAnalysis::m_bags
ClusterArray< int > * m_bags
Number of bags per cluster (stored even if vertex list is not stored)
Definition: ClusterAnalysis.h:178
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:62
ogdf::ClusterAnalysis::m_ialevel
NodeArray< int > m_ialevel
Definition: ClusterAnalysis.h:173
ogdf::ClusterAnalysis::~ClusterAnalysis
~ClusterAnalysis()
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:219
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:185
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:70
ogdf::List< edge >
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
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:96
ogdf::Skiplist
A randomized skiplist.
Definition: Skiplist.h:54
ogdf::ClusterAnalysis::DefaultIndex
static const int DefaultIndex
Definition: ClusterAnalysis.h:71
ogdf::ClusterAnalysis::m_ianum
ClusterArray< int > * m_ianum
Number of inner active vertices.
Definition: ClusterAnalysis.h:177
basic.h
Basic declarations, included by all source files.
ogdf::ClusterAnalysis::m_storeoalists
const bool m_storeoalists
If set to true (default) lists of outeractive vertices are stored.
Definition: ClusterAnalysis.h:183
ogdf::ClusterAnalysis::lcaEdges
List< edge > & lcaEdges(cluster c)
Returns list of edges for cluster c with lca c.
Array.h
Declaration and implementation of Array class and Array algorithms.
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:92
ogdf::ClusterAnalysis::m_oanum
ClusterArray< int > * m_oanum
Number of outer active vertices.
Definition: ClusterAnalysis.h:176
List.h
Declaration of doubly linked lists and iterators.
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:51
ogdf::ClusterAnalysis::m_numIndyBags
int m_numIndyBags
Definition: ClusterAnalysis.h:191
ogdf::ClusterAnalysis::IsNotActiveBound
static const int IsNotActiveBound
Definition: ClusterAnalysis.h:70
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:346
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::ClusterAnalysis::m_indyBagNumber
NodeArray< int > m_indyBagNumber
Each independent bag has a different number.
Definition: ClusterAnalysis.h:190
ogdf::ClusterAnalysis::m_oalevel
NodeArray< int > m_oalevel
Definition: ClusterAnalysis.h:174
ogdf::ClusterAnalysis::numberOfIndyBags
int numberOfIndyBags()
Returns number of independent bags in clustergraph, -1 in case no independent bags were computed....
Definition: ClusterAnalysis.h:135